Author Topic: Line follower and Logic gates simplification  (Read 18350 times)

0 Members and 1 Guest are viewing this topic.

Online MK14

  • Super Contributor
  • ***
  • Posts: 4539
  • Country: gb
Re: Line follower and Logic gates simplification
« Reply #25 on: September 14, 2016, 01:32:12 pm »
Congratulations on getting as far as you have, so far!

The motor current draw, is NOT like a fixed resistor value.

It will usually use, the least current when it is just freely spinning (unloaded), such as the 120 mA's approx, that you have shown in your picture. If you disconnected the gearbox, it would probably use even less current.

If you put lots of load on the motor, such as when it is driving on the track, the current will probably go up a lot. To something like 500mA's (guess).

If you stopped the motor from spinning. E.g. By locking it in a vice (N.B. Best to NOT try this, as it can overheat the motor and damage it), it will tend to use the most current, and may use an amp, or even a few amps, depending on the winding resistance of the motor.
This is usually called the motor stall current.

The light sensors, appear to be phototransistors. These are VERY commonly used in line followers, and many other applications.

I'm pleased that you have got reasonable results with the digital solution. But as I tried to warn you about earlier, the problem you may get, is that in order to improve it and/or get it to work properly, you don't get the adjustability/flexibility that an analogue or microcontroller based digital solution gives you.
But we should still be able to sort it out, hopefully.

Giving the motor less voltage (e.g. < 5V), should slow it down. But too low, will stop it from turning, completely. As it probably needs about 1V to 3V minimum, before it starts to turn.

Or add additional resistance to the path between the motor and the output driver.

Or reduce the current(s) going into the driving transistors bases, by making the 1K resistors bigger and/or adding an adjustable potentiometer, in series with the 1K resistors.

There may be other ways of slowing it down, such as using a higher gear ratio, in the gearbox (too late if you have already bought them, I guess. But some are adjustable within limits, by exchanging gears and stuff. This only applies to some rare gearboxes, and probably not the ones you are using. I.e. They are called adjustable ratio gearboxes and already include the right gears selection, so you can change it. Non-changeable may still be adjustable, but you would have to go out and buy/find the alternative gears and stuff, yourself, and they may not fit).

If you had used an MCU (probably a bad idea, until you are much more familiar with stuff like that), you could have used PWM (which you still can, by using hardware to create the PWM, which would allow you to slow the motors down, that way, by reducing the PWM duty cycle).

tl;dr
There are many ways of slowing the motors down. Probably using resistors, is going to be the quickest/easiest solution for you currently. Either in series with the motor (make sure they can handle the power dissipation) or in series with the base of the driving transistor (which has much less current in it, so adjustable potentiometers, are easier to put in place there, but maybe less accurate control).
« Last Edit: September 14, 2016, 01:40:52 pm by MK14 »
 
The following users thanked this post: Nexo

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Line follower and Logic gates simplification
« Reply #26 on: September 14, 2016, 01:48:07 pm »
A PWM solution would be good.  I think the light sensor section should be kept analog even if you want to use digital for the control algorithm.  That way you can have an OPAMP differential amplifier followed by a precision rectifier to get a voltage that is proportional to how well balanced the sensors are.  Use it for a control voltage for the PWM and it will speed up both motors when its tracking the line, but slow right down if it goes significantly off center.  The hunting oscillation you have at the moment is indicative of too much loop gain if its using analog tracking or of 'bang-bang' digital tracking.  You probably need to dither the inputs to get something approximating to a proportional response.

N.B. If you want better advice from us, you'll need to provide a full schematic (please not at whatever crappy image hosting site you've found - reduce it to a 16 colour GIF or PNG and attach it directly to your post here), accurate dimensioned chassis layout, measured width of line, and specs for the sensors and motors e.g part numbers, and for the motors nominal operating voltage., wheel diameter and no-load speed.   
« Last Edit: September 15, 2016, 05:09:25 am by Ian.M »
 
The following users thanked this post: Nexo

Offline NexoTopic starter

  • Regular Contributor
  • *
  • Posts: 102
  • Country: co
Re: Line follower and Logic gates simplification
« Reply #27 on: September 15, 2016, 01:52:00 am »
Thanks to both of you !

I'll start gathering all the info but it may take a few days because the LF is not with me and we have exams this week.
Now I would like to share with you a video of a new version, the last one was not working to well because the guy who was in charge of doing it, put a NAND IC instead of an AND circuit - no idea how it was working  :-DD

https://youtu.be/LNWKUFlRp8k
 
The following users thanked this post: MK14

Online MK14

  • Super Contributor
  • ***
  • Posts: 4539
  • Country: gb
Re: Line follower and Logic gates simplification
« Reply #28 on: September 15, 2016, 02:18:07 am »
I'm surprised you (and your team mates), have been able to make it work like that, by using logic gates. I would have thought it was too harsh in its control movements, and would have lost control.

Some people do come up with amazingly simplistic systems, for controlling their robots, which I find fascinating when I hear about it. Such as using just a bent paper clip, and a micro switch or two, to achieve similar results to what you just demonstrated. But it used a different type of course, where there were more physical elements which the microswitch/paper clip could track, such as a narrow wall.

I can't remember the exact details, so could be wrong. There are probably websites, with information about such things.

The disadvantage to your system, is that if you want to refine and/or improve it. E.g. to be smoother, more reliable and/or faster. You would have little capability to do that. But if it had been implemented in a microcontroller. You could improve/expand/tweak your program, to make it better and better.

But for your purposes, of achieving marks in your academic practical test(s), it has/is achieving its purpose, and does not necessarily need a microcontroller or high speed, etc etc.
« Last Edit: September 15, 2016, 02:20:10 am by MK14 »
 
The following users thanked this post: Nexo

Offline NexoTopic starter

  • Regular Contributor
  • *
  • Posts: 102
  • Country: co
Re: Line follower and Logic gates simplification
« Reply #29 on: September 15, 2016, 03:18:47 am »
Thanks!

Well, the secret was to add some kind of a breaks near the wheel because we made some calculations:

The radius of the wheel is: 33 mm so in one turn it would travel 20 cm and the motor has 100 RPM so no wonder why it was "yawing" that much, it still is but we've been able to figure it out and at least it has improved quite a bit.

So we pretty much have two options here, we are hoping to implement both, though:

1. Find a smaller-radius wheel, for example half the one we currently have (hoping it fits on our LF) that way, with each turn, it would travel just 10 cm, thus, it wouldn't yaw to much.

2. Use 2 Timers 555 in order to be able to control the motors.

Now, I team mate stated the following: "we should use an electrolytic capacitor -in the power module (motors) so when the motor stops it would reverse its polarity thus making it turn in the opposite direction for a few milisecs.

What do you guys think about this idea?

Again, thank you for being so helpful!
 

Online MK14

  • Super Contributor
  • ***
  • Posts: 4539
  • Country: gb
Re: Line follower and Logic gates simplification
« Reply #30 on: September 15, 2016, 03:30:16 am »
Tweaking it in ways similar to what you suggest, may be able to improve it. The backlash in the gearbox, may prevent/minimize brief reversal of the motor, from giving you better results.
Also motors tend to be somewhat slow to respond to very quick signals. Ironically, your original idea of the stepper motors, may have responded faster (I'm not 100% sure about that though).

But messing about with extra 555 timers, could allow quick/simple modifications, which would either improve it or not. So you could quickly experiment, and keep improvements, and leave off if it makes it worse.

H bridge motor control, would have allowed easy motor reversal, by the 555 timer (or an MCU).

Lowering the voltage to the motors and/or limiting the current to the motors, will also provide a quick way of slowing it down, or better still (but more complicated), is to PWM the motors. Very slow motor speed, probably needs PWM, otherwise the motors will tend to just stop/stall, because of a lack of minimum voltage requirements.
So PWM is probably the best way of achieving slow, controllable speeds, and yet keeping the torque up.
 
The following users thanked this post: Nexo

Offline NexoTopic starter

  • Regular Contributor
  • *
  • Posts: 102
  • Country: co
Re: Line follower and Logic gates simplification
« Reply #31 on: September 15, 2016, 03:48:24 am »
Tweaking it in ways similar to what you suggest, may be able to improve it. The backlash in the gearbox, may prevent/minimize brief reversal of the motor, from giving you better results.
Also motors tend to be somewhat slow to respond to very quick signals. Ironically, your original idea of the stepper motors, may have responded faster (I'm not 100% sure about that though).

But messing about with extra 555 timers, could allow quick/simple modifications, which would either improve it or not. So you could quickly experiment, and keep improvements, and leave off if it makes it worse.

H bridge motor control, would have allowed easy motor reversal, by the 555 timer (or an MCU).

Lowering the voltage to the motors and/or limiting the current to the motors, will also provide a quick way of slowing it down, or better still (but more complicated), is to PWM the motors. Very slow motor speed, probably needs PWM, otherwise the motors will tend to just stop/stall, because of a lack of minimum voltage requirements.
So PWM is probably the best way of achieving slow, controllable speeds, and yet keeping the torque up.

My exact same thoughts (at least the PWM part  ;D)

The problem with lowering the voltage is that it doesn't reduce the motor speed. We supplied 12V, then 10V, then 7 V and the speed was pretty much the same but it we supply less than 6V, it will stop rolling and we are also using a LM7805 in order to supply 5V to the sensors.

Now, would it be a good idea to reduce the current supplied to the motors? I guess it would but I don't know how to achieve it. Maybe placing the motors in parallel so the voltage would be the same and the current would be half the current value when moving.

I would love to know your opinion on this idea.

Thanks!
 

Online MK14

  • Super Contributor
  • ***
  • Posts: 4539
  • Country: gb
Re: Line follower and Logic gates simplification
« Reply #32 on: September 15, 2016, 10:18:55 am »
My exact same thoughts (at least the PWM part  ;D)

The problem with lowering the voltage is that it doesn't reduce the motor speed. We supplied 12V, then 10V, then 7 V and the speed was pretty much the same but it we supply less than 6V, it will stop rolling and we are also using a LM7805 in order to supply 5V to the sensors.

Now, would it be a good idea to reduce the current supplied to the motors? I guess it would but I don't know how to achieve it. Maybe placing the motors in parallel so the voltage would be the same and the current would be half the current value when moving.

I would love to know your opinion on this idea.

Thanks!

Motors can become very complicated.

The voltage you supply to the motor. E.g. 12 volts, will allow it to build up speed to a certain RPM (the RPM is NOT fixed, it depends on load and other factors). But motors take time to build up the RPM (and hence speed etc). So although you are giving it 12 volts, its RPM may be a lot lower at this exact point in time, as it will take time to accelerate up the RPM which it can potentially reach with that voltage (and current drive capability).

I.e. The motor is not at its final RPM for that voltage/load, until the robot has reached the max velocity for that motor power/voltage/current value. This takes time, and may not even happen, if the load/gear-ratios don't allow it. I.e. the RPM may be held back because the motor has not got enough "push" to accelerate any more. Anyway motors get rather complicated, when you get into the finer details.

This is why I keep on rattling on and on about using Microcontrollers (N.B. I fully agree that it is probably WAY, WAY too soon for you to use MCU's yet. As it needs lots of knowledge and experience etc, to use them well, and they are rather complicated until you know about them).

But the MCU would be able to use quadrature decoders (or other methods), and hence know/read the exact wheel/robot speed. N.B. The wheel rotation speed can be different between the left and right hand sides, and it can even be different from what the robots velocity is (e.g. Wheel spin/slip etc).

Once you know the wheel speeds, robot velocity (estimation) and can PWM the motors inside an MCU, using a PWM'ed H bridge motor drivers, plus position sensors (line sensors), and maybe even accelerometers and gyroscopes etc etc.

You can create/use algorithms to make sensible choices about how you will react.

What you are trying to do, is tweak the robot (line followers) performance, using rather simple/crude means, which are mostly ignoring the wheel speeds, robot velocity/direction, etc etc. Hence in many cases your attempted tweaks will not work well.

You can limit the current, but it can reduce the torque too much, and potentially stop/stall the motor and/or give it too little torque. My understanding is that PWM gives better results, because during the "ON" parts of the PWM duty cycle, it effectively gives the motor (potentially) the FULL current, and hence tends to maintain reasonable torque WITHOUT stalling the motor, too badly.

This is why (if I understand/remember things correctly), drill speed controllers, are also best done using PWM techniques or similar. Otherwise the drill bit becomes too weak (too little torque), to successfully drill into the materials that you want to make holes in.

tl;dr
You may have to accept the fact that without using a microcontroller, and extra sensors and better ways of controlling the motor. You are going to be rather limited in ways that you can improve its performance.

But don't let me put you off too much. There are going to be improvements to be had, I would imagine.

Going the microcontroller route becomes EXTREMELY involved, complicated and time consuming, going well beyond the kind of technical resources and time, I expect your team intend to put into this project. People who do work like that, are usually already Electronics and/or software experts, to at least some extent. But even beginners sometimes have a go at stuff like that. There are also kits available (probably not suitable for your studies as it would probably be considered cheating).

EDIT:
Please DON'T be too put off by my mentioning MCUs. There are many, many ways of doing Line followers, which people use which DON'T involve mcu's, and their performance can be quite good, maybe even very good. In principle line followers, is simple enough to do, without MCU's.
I'm just way too biased in favour of MCU's, and this bias seems to be leaking out too much in my answers.
Sorry!
« Last Edit: September 15, 2016, 10:45:09 am by MK14 »
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Line follower and Logic gates simplification
« Reply #33 on: September 15, 2016, 11:15:57 am »
For future consideration.

You mentioned you are doing this discretely to learn rather than use a UP approach. That
logic then would have you do this all at the transistor level. All of us have to jump into tech-
nology at a further point down the timeline of discovery, relying on past development and
knowledge. I will stop pontificating  :-\

Cypress PSOC has ARM core, A/D (SAR and DelSig), DSP, logic fabric that can be used at
a GUI level or programmed in Verilog (much more important in future career), DMA, OpAmps,
PWM, COM, onboard Vref......see attached "component" list. In PSOC a component is a piece
of onboard HW. PSOC has LUTs and basic gates, counters, shift regs....you can either config
with GUI tool or program in Verilog. Tons of training videos, tool has many example project
solutions you can draw from. All components come with APIs you use in code to operate the
various components.

You can even design your own components, as well as program DSP engine in ASM to create
high performance custom DSP designs. DSP is a separate core inside PSOC.

Component list attached, as well as an example using DSP to filter a signal. Note this only used
a small %age of the resources, eg. one could have added a lot more functionality to the project.

Keep in mind you route the signals internally and to pins, with the GUI tool. its its own
breadboard, FPGA like.

SW tool free, low cost boards, $ 10 - $ 25.

Regards, Dana.
« Last Edit: September 15, 2016, 11:26:04 am by danadak »
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf