unstable picaxe08 outs

banderkerkoff

New Member
I´m trying to make a light sensor robot. It´s a simple circuit with a Picaxe 08 and a uln2803 to control two 13v dc motors.
The circuit is bilt with 2 LDRs controling each motor and making the robot turn right or left.
The left LDR sends HIGH or LOW to In3 and the rigth LDR does the same to In2.
It works good!!
The program generates high or low signals in out0 and out1 in the picaxe08.
The out0 really works good but the out1 works in a unstable mode. It changes its state with a delay and some times out1 never changes its state. Sometimes both outputs keep giving a hold state and I must reset the circuit to go out.
I´m using two diferent power supplies, one for picaxe a other for the motors.
I conect the serial in pin (2) to ground through a 10k resistor.
What am I doing wrong?
Thanks a lot
 

BeanieBots

Moderator
Welcome to the forum.

Sounds like you have an anlogue signal from the LDR being read by a digital input. Depending on how you have implemented the sensor, it could give erratic results.

Please post a full circuit diagram and code so that we can look into it with more detail.
 

banderkerkoff

New Member
I`m sendin to you the circuit!!!!
the program is very simply.
main:
if pin2=0 and pin3=0 then stopp
if pin2=1 and pin3=0 then left
if pin2=0 and pin3=1 then right
if pin2=1 and pin3=1 then go
goto main

stopp:
low 0
low 1
goto main

left:
high 0
low 1
goto main

right:
low 0
high 1
goto main

go:
high 0
high 1
goto main
 

Attachments

hippy

Ex-Staff (retired)
It may be 'radio interference' generated by the motors causing incorrect operation of the PICAXE, or drawing too much current from the supply and collapsing power to the PICAXE.

You can take your LDR's out of the equation by writing a program which just drives the motors. You need to home in on exactly what is at the root of the problem.
 

inglewoodpete

Senior Member
Whenever you use inductive loads (relays/solenoids or motors) with a PIC, you have to take lots of precautions to keep the electrical noise out of the PIC.

Mount a 100nF capacitor across the power pins of the PICAXE, as close as you can to the chip. Also, put a reverse diode across each motor as shown in the PICAXE interfacing manual (cathode to the +ve side). Read "Ouput Devices 5" in manual 3 about supressing noise from a motor.
 

slurp

Senior Member
I often find that there is variation between line (or light) sensors, I think this is not so much an unstable output but an unstable input.

As BeanieBots suggested your putting an analogue signal into a digital input. If the signal is in the voltage range between Input Low and Input High then it's not going to be stable.

I think the undetermined input will occur between 0.8 and 2.0 volts but this is based upon TTL buffer inputs. With a meter you should be able to compare your sensors to see if this holds true.

Things that might affect how one sensor is operating compared to the other include variation in ambient light (one side of line follow compared to the other) and small differences in position of sensors in relation to surrounding surfaces.

Solutions can include tweaking the position of the sensors, changing the resistors in the potential divider to get a better voltage range on the input or if you have the 08M version of the picaxe use ADC input and use differing threshold values for triggering the motor output.

best regards,
colin
 

slimplynth

Senior Member
i would have chosen Slurp's answer of using the ADC inputs.. id have thought some kind of self calibration subroutine would be useful too. the code below works in the simulator to just to give you an idea of what I mean.

Code:
main:

readadc 1,b0
readadc 2,b1

b2=b0 + 30
b3=b1 + 30

if b0>b3 then goto left
if b1>b2 then goto right

high 0
high 4

goto main

left:
high 0
low 4
goto main

right:
low 0
high 4
goto main
 

banderkerkoff

New Member
thanks!!! It works now.

I connected a 100nf capacitor between pin1 and pin8 to filter the picaxe power supply. Now I can use the same source to supply the picaxe and the motors without any problem. The robot works perfectly!!!
I couldn´t use adc1 and adc2 because I haven´t a 08M. My picaxe is a 08 one.
This was my first experience in this forum and I´m really happy. You are so good!!!! thanks!!! and please forget my bad bad bad english.
 
Top