Friday, 6 November 2020

New Arms


The first arm I made for my robot turned out to be a little on the small side.
Also it did not do much, as it was driven by just one motor.

So I decided to make new Arms.
To have arms do lots of different movements needs lots of motors, I want to keep this to a minimum.
I will be using DC motors.
To control a motor properly you need feedback from the motor or whatever it is moving.
As a minimum you need stops at its limits and some sort of position counter.

I have already made a driver for the Pen Lifter and Platform Lifter which only needs one control signal and has stops. With this setup the motor always travels to the extremes. I will need to modify this driver so that I can stop the arm motors at any position and know what that position is.

I have come up with a circuit form my new motor driver.
It will require five pins on a microprocessor controlling it, one for forward, one for reverse, one for position feedback and two for the stops feedback. That's quite a lot of pins for controlling a motor.
So this is going to limit the number of motors I can use if I just want to use a Nano to control all arm motors. I am going to use the AtMega168, I don't need to much memory (well I will find out).
To increase the number of pins the Nano has use of, I decided to add another MCP23017, this gives me 16 more pins.

I decided I would just have six motors, three in each arm. One for the shoulder, one for the elbow and one for the hand grip.



That's going to need 30 pins on the microprocessor. Actually it will be just 24, I am not going to have feedback from the Hand Grips at the moment.
Although the Nano has 22 GPIO pins, on the Nano I still need two for I2C, two for TX/RX and two for getting interrupts from the MCP23017. This leaves only 16. 
So I have decided to use 12 pins on the Nano to control direction of each motor, and use 12 pins on the MCP23017 for feedback from the motors.
    
The MCP23017 is split into 2 ports, so I am going to use one port for the left side and the other port for the right side. This way the two interrupts will be one for left and one for right.

I am going to put all six motor drivers on one PCB, I am also going to have a go with SMD's (Surface Mounted Devices).
So with this in mind, I have decided to have the BCP made by a professional manufacturer.
The PCB Manufacture I chose was PCBWay, this is the first time I have had a PCD made by a manufacturer of PCB's so I am going to do a separate post on how I designed the board and got it manufactured.

The result looks like this:

 

With components and Fitted:


Now all I have to do is figure out how I am goring to fit the stops and counter to the motors.
In the past I have use an infrared sensor and shutter system to count movements like I have for the riser on the chassis.

The size of these makes it very impractical, I have seen smaller versions, I have some I salvaged from old printers.
Then I remembered about the 3144 hall effect sensor, it is small and magnets come in all sizes.
I thought of the magnetic strip, this can be cut into any size.
I did some experiments to see if was strong enough when cut into small pieces.
It worked great, I had to find its polarity and mark it up before cutting so that I placed them in there correct orientation.

For the shoulder motor I glued the magnets into a holder I made, so that it could be fitted to the top of the shoulder.

I made a small circuit board for the sensor which could be mounted to the frame.

As the arm rotates about the shoulder the magnets pass in front of the sensor, switching it on and off.
This enables the microcontroller count it's position.

Next was to add stops so that the motor would not go beyond it's limits and the controller would know when to start counting from.
I was able to modify the shoulder mount to hold two switches and I made two adjustable stops that fitted around the shoulder joint.

The motor for the forearm was a little easier.
I used a hall effect sensor again, but this time I cut a piece of magnetic strip into a disc, which I was able to placed on the drive shaft.
This gave me a lot more accuracy, as the disc rotated one revolution, it turned the sensor on and off three times, the sensor had to be in just the right position, if it was out of position it only turned on and off, once every rotation. 
The switches where mounted as I had done for the platform lifter.

For the hand I have just fitted stops for open and close.
The close switch detects when something has been griped.






If you like what I have done, or want to know more.
Please leave a comment below.



Wednesday, 29 July 2020

LED Matrix


I wanted to give my robot that retro look, so I decided to add a matrix Display.
I wanted it to be independent of the main controller, I did not want the main controller to control it all the time.
So I added another small processor to control it and the main controller just sends a task for it to do via the I2C bus.

The Matrix Display is made up of four 8x8 LED matrix, each controlled by a MAX7219 (Serially Interfaced, 8-Digit LED Display Drivers)

I got cheep one with a single PCB with four 8x8 LED displays attached from eBay.


If you look closely at the image above you will see gaps between the 8x8 Displays.
This is because the PCB is designed for Metric Displays which are 32mm x 32mm.
The ones fitted to this PCB are Imperial, which are 1 1/4" (inch and a quarter = 31.75mm).

As I was going to mount them in a 3D printed frame, I fixed this buy cutting the PCB into four separate pieces, the saw thickness was enough to remove the amount needed to bring the 8x8 displays together.


All I had to do was bridge the five lines at each joint.





The processor I chose to control the Matrix Display is an ATTiny85.
I found an SMD version on a breakout board with a USB connection on the board (GY Board, Digispark clone), on eBay.

This worked well, but if you look at the video, you will notice Scanning when the display changes.
This is because the Arduino library updates the screen every time it draws a column. I assume this is to keep the library footprint as small as possible, and not use a buffer to write to first, which makes it more versatile to how many devices are connected together. (It is possible to connect eight MAX7319 end to end)

As I am not going to change the number of 8x8 displays, I am going to write my own commands to write to the Matrix Display, using a buffer to send the whole display to the matrix at once.
This way the Matrix Display will change instantly without any scanning seen.

I have currently re-wrote my code for the Matrix Display.
I wanted to be able to send text to it from my phone application, so that any messages can be displayed.
This requires a font. Adding a font to the program made the code too large for the ATTiny85, even when I reduced the font to just capital characters and numbers.
I am over by 66 bytes. I trying to remove some more code to fit it on.
If I removed the numbers from the font as well, it would reduce it by another 50 bytes. (not quite enough)

Then I thought what about using an ATMega168?
Looking on eBay the price of an ATMega168 and ATTiny85 are pretty much the same.
The reason I originally chose an ATTiny85 is because I thought it was the cheapest option, and I thought I wouldn't need a lot of memory. But as soon as you start to use buffers and fonts, memory becomes an issue.
As space and size is not an issue, I may as well use an ATMega168, it gives me twice the memory and a lot more pins, I could have the ATMega168 control something else later.


What I may do for a prof of concept, is continue with the ATMega168.
Then when I have it as I want it. Because I am using the I2C bus to communicate with everything, is put the font on an AT24C256 Module. Then see if the code fits on a ATTiny85.

I managed to put the font onto the AT24C256 for the ATMega168 to use.
But because I wanted to add more functionality to the program, the code it still to large for the ATTiny85.
I have modified my Application from my phone so that I now can send any message I want to the display.
It also holds 5 pre-sets so that I can send commonly used messages quickly.


I love is when people comment, some times it give me an idea.
One did, I'm not ready to do text to speech yet, I'll try that when I come to build the head.
But I thought: Android/Google API has the ability to do voice recognition, so use it hehe.
I decided to add this feature to mi application.

I haven't made it send the word spoken straight away, I put send it on another button, so that the word it thinks you say can be checked first.
It save all that typing haha.


Have managed to get the program to fit on the ATTiny85, didn't realise I was using a float for command selection, soon as I changed it to an Integer, I had a lot more memory to play with.

The setup now looks like this:

The Android device sends a command to the Bluetooth Module, which is connected to the Arduino NANO RX and TX pins. (via a voltage changer)
If the command is for the LED Matrix, the Arduino NANO sends the command to the ATTiny85, via the I2C Bus.
If the command is a function command, the ATTiny85 carries out the function.
Functions are:
On/Off.
Scroll.
Chevron Display.
Retro Display.

If the command is to display a message, the ATTiny85 will read the message and get the required Fonts from the AT24C256 Memory Module, via the I2C Bus.
Then display them on the LED Matrix as it retrieves them for the memory module.

It's a display, what more could I display with it?
Oh just realised I could add a RTC (real time clock) to the I2C bus.
So I did.
The processor I am using to drive the LED Display can now get the time from the RTL and display it.


While doing this I have learnt how to give voice commands to my robot.
So later I intend to do another menu on my controller application to control more functions by voice commands.


The RTC I was using did not come with a backup battery, so while looking for a battery for it, I found another RTC with a memory chip on the board as well as the clock chip.
This was cheaper than buying a battery for the current board, and it came with a backup battery.
The memory chip is only a 24C32 which is enough to fit the font.
This board replaces the previous RTC and 24C256 modules.






If you like what I have done, or want to know more.
Please leave a comment below.








Saturday, 18 July 2020

Line Sensors




One of the easiest way for a robot to navigate, is to follow a line.
So it's time to add the some line sensors.
I got several types of eBay:
   
This was the first type I tried, it has a TCRT5000 infrared transmitter/receiver, with a 74HC14 which is a hex inverter with Schmitt-trigger inputs.
Having no comparator, this type is only good for detecting objects.
Didn't matter the colour of the object, (black or white) it detected proximity.

Next I tried, one with a TCRT5000 infrared transmitter/receiver and a LM393 comparator.
   
This had a potentiometer that would adjust the sensitivity of the infrared receiver.
This worked in a fashion, but the black line has to be a black that absorbs infrared well.
To mount this I moved the potentiometer and pins to the opposite side.
I decided to try another.
This is similar to the last one except the infrared transmitter and receiver are separate components.
    
This worked just like the last one, but because the infrared transmitter and receiver are separate components, I decided to swop out the infrared receiver for a Light Dependent Resistor, and change the infrared transmitter for a normal Light Emitting Diode.
I also rearrange them and the pins.
   
I found for following a black line this setup worked best.
The only down side to using LDR is; I will have to always adjust for ambient light or use a shade when it is bright outside.

There are several options in using sensor(s) to follow a line, in fact there are lots, too many to mention them all.
I will show a few:

With one sensor it actually follows an edge.
The line needs to be quite wide.
Looking at the image above, if the sensor detects black, it will turn right, if it detects white it will turn left.
If using DC motors, this could be made to work using a few transistors to switch the drive motors on or off.
I have stepper motors, not impossible but not good.

With two sensors there are a couple of ways to follow a line.
Have the sensors outside the line, the line can be quite narrow.
Have the sensors inside the line, the line will need to quite wide.

I have decided to use three sensors and arrangement the sensors in a triangle configuration.

Having three sensors gives me more control.
The two outer sensors work in the traditional way, using feedback from these two sensors, the wheel speed is adjusted to keep the sensors either side of the line.
Wheel speed is changed, rather than switching motors off/on, because I have stepper motors.
The middle sensor acts like a preview of what's ahead.
If it is still on the line, then only small adjustment to the speed of the wheels is needed.
But say it comes to right-angled or sharp turn then the middle sensor will leave the line, indicating larger adjustments to the wheel speed is required.







If you like what I have done, or want to know more.
Please leave a comment below.


Friday, 17 July 2020

Right Arm



I want to make top section it look like a traditional robot, so the next step is to give it Arms.
I have started with the Right Arm.

I am going to make the first design basic using one motor to move it.
I found this motor on eBay:
 I think it was originally made for a lock mechanism, the output can only turn back and forth 90 degrees.
It was advertised as being 3v-5v, but when I wired it up, 5v was very slow, I ramped it up to 12v.

To control it I added an L298N_Module.


Although I am only using one motor, I have designed it with levers so the elbow and wrist move to keep the hand level.

The frame in this animation is taller than the one in the video.
I decided that the arm was too small to be of any use.
I have ordered some more of the small motors with gearboxes, when I do the left Arm, I am going to make it larger and try and make all the joint move separately.
Also I want to give it a hand that grabs.

I have made new Arms for it.
I now want to make a custom driver board to control them.
I have added a motor to move the forearm independent to the upper arm, also added a motor to the hand. The hand now opens an closes.
I also need to work out some feedback to get the positions of the joints. I don't what I am going to use to do this, so it's time to do some experimenting.





If you like what I have done, or want to know more.
Please leave a comment below.