readadc understanding / broken chip ?

rontv

New Member
Help, i'm a bit lost

I'm trying some basic circuits to use on my robot for sensors (the bot with 3 servo's on the 18 projectboard with 18x is doing well in its self for the routine i have loaded, now i want to add sensors)

i tried the ldr circuit as in the manuals and the following lines

readadc 1, b0
debug b0
sertxd ("value is" , #xb0, cr, lf)

Funny thing is on the projectboard i do not get any data at all (not in debug, not in the terminal)
adapting it for the 08M board, i get data but with varying numbers despite not changing light conditions.

so how will things work if i want to use a certain level in a "If" statement if the data changes all the time (looks like its alternating between two levels) as on the 08M board

as i also can't get the statement: if pin1=1 the.... working on the projectboard (despite the voltage connected 3,5 - 4,8v) do you think the board or chip is broken on the input side?

rgds
Ron
 

SilentScreamer

Senior Member
so how will things work if i want to use a certain level in a "If" statement if the data changes all the time (looks like its alternating between two levels) as on the 08M board
What two levels is it alternating between?

If they are close then you can use something like this:

Code:
if b0 >= 15 and b0 <= 20 then
It will be true whenever b0 is 15, 16, 17, 18, 19 or 20.
 

manie

Senior Member
Rontv: If any action is taking place that could produce a slight voltage drop while the chip performs a Readadc, then it could also show a varying value. Check the supply voltage if you can, while the code is running...
Manie
 

rontv

New Member
readadc

What two levels is it alternating between?

If they are close then you can use something like this:

Code:
if b0 >= 15 and b0 <= 20 then
It will be true whenever b0 is 15, 16, 17, 18, 19 or 20.

hi silentscreamer
its strange
its varying between 58-65 and 128-130 on the 08M board. on the 18x project board i dont get anything at all

Ron
 

rontv

New Member
readadc

Rontv: If any action is taking place that could produce a slight voltage drop while the chip performs a Readadc, then it could also show a varying value. Check the supply voltage if you can, while the code is running...
Manie

Hi Manie
i'm not doing anything besides this
thing is it doesn't work at all at the 18 project board (as mentioned not even getting an input high)
i therefore tried it on the 08M board. i get data but varying arounf two levels 58/65 and 128/130

Ron
 

SilentScreamer

Senior Member
Do you have a multimeter? If so disconnect the battery that is supplying the project board and then measure the resistance of the LDR. Is it stable or is it changing?
 

westaust55

Moderator
i tried the ldr circuit as in the manuals and the following lines

readadc 1, b0
debug b0
sertxd ("value is" , #xb0, cr, lf)


rgds
Ron
Ron,

In the sertxd line you have "#xb0".
With that 'x' there it will not compile and you would get a syntax error.

Please:
1. cut and past from the PE your exact program as used for the 18X and for the 08M.
2. Please upload your schematic (Circuit) diagram for folks to review.

That voltage range you mention in post 1 is quite a range.
"... working on the projectboard (despite the voltage connected 3,5 - 4,8v) "

Is that voltage well filtered and decoupled with capacitors?
What happens when you ahve a steady voltage like 4.5 or 5Vdc?
 

hippy

Ex-Staff (retired)
@ rontv : Welcome to the PICAXE forum.

It sounds to me like you have a circuit or mis-wiring issue rather than anything else. As the 08M appears to be working better than the 18X it makes sense to start with that and see if we can resolve the problem.

First thing is it's usually DEBUG or SERTXD but it is possible to use both, and it often helps to have a short delay between readings -

Do
ReadAdc 1,b0
SerTxd( "ADC 1 = ", #b0, CR, LF )
Pause 500
Loop

Disconnect the servos, other sensors and without the LDR circuit, a 1K resistor from 08M Pin 1 ( leg 6, third down on the RHS ) to +V should read at or near 255, to 0V should read 0. With two 1K resistors, one to +V the other to 0V, the other ends joined together and to pin 1 you should see something like 128. It may not be exact but should be fairly constant and only vary over a small range.

Give that a go and see what happens. Repeat with the 18X.

If you have a pot, you can connect it across +V and 0V with the wiper to 08M pin 1 and that should give a reading of between 0 to about 255.
 

BeanieBots

Moderator
Rontv, can you describe EXACTLY how you have wired up the LDR.
It sounds like you just have the LDR connected to an input without the other resistor which forms a potential divider.
 

rontv

New Member
Hi people,

thanks sofar for all respons.
I'm just back from a business trip but will give all things mentioned a try

As for the ldr wiring. Its not straight up but setup as a divider

Somehow it just looks like the "high" on teh input is not recognized as one

rgds

Ron
 

inglewoodpete

Senior Member
readadc understanding / broken chip
vs...
Somehow it just looks like the "high" on teh input is not recognized as one
Are you reading the logical value or the ADC value? Your statements appear to conflict.

As requested proviously by others, please post your code and circuit, along with voltage readings taken at the input.
 
Top