Let's Make Robots!

Picaxe 28x1 Digital input and output programming help. :D

I got some digital line sensors. I am trying to do these steps:

Set the I/O line to an output and drive it high
Allow at least 10 us for the 10 nF capacitor to charge
Make the I/O line an input (high impedance)
Measure the time for the capacitor to discharge by waiting for the I/O line to go low

Here is my code currenly for testing.



high portc 0
pause 10
low portc 0
pause 10
high portc 1
pause 10
low portc 1
pause 10
debug ' this draws out all variables to the editor. 

goto main

And I do not see anything changing in the debug panel. I have searched on this site and used the ping node for this start to the code. But I dont think I am changing it back to input before putting it to low. I am looking over the Picaxe BASIC manual and am unable to find what I am looking for. Please help.

Here is the link to the type of line sensors I have. I have 2 of them. http://www.pololu.com/catalog/product/959

I do have them connected correctly and have double checked that. And I am using pin0 and pin1 for the digital inputs. :D

Thanks for your help. 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.





LET DIRSC = %00000000

PULSIN 1, 1, W0

debug ' this draws out all variables to the editor. 

goto main

it is still 0. Maybe I am getting a time out error? This is in the picaxe manual and perhaps that is my issue?

The pulsin command measures the length of a pulse. In no pulse occurs in the timeout period, the result will be 0. If state = 1 then a low to high transition starts the timing, if state = 0 a high to low transition starts the timing. Use the count command to count the number of pulses with a specified time period.

I just saw an error with my code. Changed it and still the same thing... I have a sensor on pin0 and pin1. 


let dirsc = %11111111

high portc 0

high portc 1

pause 10

let dirsc = %00000000

pulsin 0, 1, w1
pulsin 1, 1, w2

debug ' this draws out all variables to the editor. 

goto main
when I do the pulsin is that on the wrong pin maybe? for pin 0. Because when I do the pulsout on pin 0 my servo moves. :(
I now hate Picaxe digital. lol

vin to +5 volts on the picaxe board right by digital input pin that I am using.

ground to ground on board.

output is to digital input on the board. Multimeter tests confirm it is getting power. 

and I get readings above 200 for both sensors. It fluxuates a little. Thats on the analog pins. On the digital pins I still get 0 with my code. :(

I guess I just need to buy the analog ones. Pololu has analog ones too. I didnt know that when I bought the digital ones.

Thanks for helping. 

The one you can buy for the 28x1. http://www.hvwtech.com/products_view.asp?ProductID=495

And am using this node for the pin layout. http://letsmakerobots.com/node/75

I was using digital pin 0 and 1 and with analog was using 1 and 2. And the voltage and ground were connected to the voltage right by the input pins for both analog and digital. And the grounds were on the grounds right by the 28x1 chip on the top of the board.

Was that not correct? 

Could the problem be that the use of pulsin above is looking for a low to high transition, when it should be looking for a high to low? 

pulsin 0, 1, w1  ' times a low to high transition on pin 0 and stores the result in w1

pulsin 0, 0, w1  ' times a high to low transition on pin 0 and stores the result in w1

I think the second version should be used, since you "high" the pin to start with, then are to time the discharge to "low". 

still no changes in w1 it just stays 0. :( oh well maybe I just need something that is compatable with the picaxe board or something.