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.

Thursday 16 July 2020

Pen Mechanism





To make it draw I needed a platform held between the drive wheels.
This platform has to be held exactly central to the wheels and move with the wheels when raised and lowered.

Rather than use a servo, I wanted to control the lifting and lowering of the pen using just one wire. (on/off)



Testing that the pen is in the centre between the wheels.


After adding the pen mechanism to the robot (I want it to be able to draw on the floor). I found that I had no clearance for the robot to drive over low obstacles (floor rug).
So I needed to fit a mechanism to rise the pen platform.

I found another nice little geared motor with an M3 threaded bar, on eBay.
With this I made a lifter to rise the Pen and sensor platform.


I made circuit boards to control the pen lifter and platform lifter.
Both the Pen Lifter and the Platform Lifter work in the same way. (single wire, on/off)

Making a circuit board to control these two motors, means the program does not have to wait for the motors to compleate there task.












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


Monday 13 July 2020

Rotory Platform


It's now time to build up the next section, I want to have the torso of the robot to be able to rotate.
There are also going to be some wires that have to go from the drive unit to the torso unit, to communicate between the several micro processors I intend to use.
This would mean that torso would only be able to rotate a limited amount clockwise and anticlockwise.
I want it to be able to rotate as much as it likes without wires getting twisted up.
I found a nice little slip ring on eBay.

With this, the torso section will be able to rotate as much as I want it to.

The slip ring module has bearings in it so it will act as my centre Bering in my rotary platform which the rest of the bot will be built off.


I also included a photointerupter sensor to the rotary platform, so that I will be able to set the torso facing forward.


The rotary platform is quite simple, it has a centre fixed bearing that keeps the platform from moving horizontally whilst letting it rotate. The pairs of bearings around the outer edge, hold the platform in it's vertical position.







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

Drive Height Adjustment

With the wheels now sorted, it's time to design the lifting mechanism.
Here I had two options again;
Have two motors, one for the front and one for the rear, with sensors to synchronize them.
Have one motor with different gears to front and rear to keep it level.

I went for one motor, this will ensure both wheel move relative to each other, they will need different gear ratios on each, because the front is just an arm rotates about a centre. The rear however is a wishbone configuration, because I need to keep the rear wheel assembly in a vertical alignment.


There is no actual need for this to raise and lower, I saw it some were on an other robot.
I thought is would be a good exercise to see if I can do it, all my projects are challenges to see what I can do.
My first idea to drive the raise system was with an other stepper motor so I could set it a what ever level I wanted.
I started drawing it with a worm pinion and gear.



Then I had a sleep, the next day I thought, the breakout board I am going to use to control the stepper motors has only 3 drive slots.

I need two for the front wheels and I will need one to rotate the torso, so I decided to use a DC motor with gearbox, I will add sensors to determine the position of the wheel arms.
I did some shopping around on eBay and found this:






Had to wait for it to arrive, so I could draw it accurately. During that time, while I was trying to print a perfect worm pinion to fit a gear, I came up with a better idea, I decided to use a worm pinion and rack, a lot easier to print.




Because I decided to use a DC motor I need to add some sensors to determine the position of the wheel arms.
I am going to have to use two photo interrupters, one to indicate fully up, and one to count increments.
This means that I will have to write into the program a sequence where it will reset its count to zero when it is fully up on switch on, so that its known position is correct.

You can see from the animation that there are two gears under the rack that goes back and forth, the front gear originally drove the front wheel arms, but after modifying it to make it narrower, so that it would traverse my furniture, both the front and rear wheel are raised and lowered from the rear gear.
The front gear now just supports the rack and shutters for the position sensor.




The lower sensor counts the position, the upper sensor detects when the rack reaches the end and sets the count to zero.
I used these sensors from eBay. They have an LM393 comparator so the signal is digitised.
Also on the shutters, I used a indelible marker pen to coat the sides with black ink. This is because PLA plastic is quite transparent to infrared light.
Here is a demonstration using a light sensor without a comparator to show how the ink makes a difference:


I am now able to raise the bot to whatever position I choose.


After a While.



As I keep adding to the robot (I can call it a robot now, It does things on its own).
It is getting heavier and the riser motor struggles to lift it up and down.
I had a thought, if I make the worm drive out of PTFE, may be it would reduce some of the friction on that drive.
This required another strip down.


I decided to replace the original red worm drive shown above, with the new blue one with PTFE thread shown below.


I also tried a 5 volt motor and gearbox to see if this improved it, but the 5 volt motor was not up to the job.
Replacing the 12 volt motor with the PTFE gear did improve it, but not enough.
I decided to replace the 12 volt motor with one that has a slower reduction gearbox, so I can still have this function working.
Having a gearbox with a lower reduction speed also put less strain on the motor which let it run at a faster speed, so the speed at which the body of the robot raises did not alter too much.

If it starts to struggle again, I may have to come up with a different design to raise the body of the robot.





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