BasicMicro - Forums

www.basicmicro.com
It is currently Sat Feb 04, 2012 7:14 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: AtomPro and Devantech SRF05 pulsin code question
PostPosted: Wed Aug 04, 2010 7:25 pm 
Offline
Citizen

Joined: Wed Aug 04, 2010 6:55 pm
Posts: 7
Location: Colorado
I'm banging my head against the wall on this. I'm using the Lynxmotion Mini Atom Bot Board with an AtomPro 28 and a Devantech SRF05 and am getting some conflicting info. The ranger should pulse then raise the trigger pin high and listen for the echo. When the echo hits, it lowers the pin. What that means is I should be looking setting the pulsin direction to 1 but that doesn't work. It returns a zero meaning it timed out. When I set it to 0 it actually works. Am I missing something???
Code:
srf05 con p4            ' DEFINE THE VARIABLE FOR THE PIN
range var Word             ' DEFINE THE VARIABLE THAT WILL STORE THE RANGE
main:                  
low srf05               ' LOWER PIN
pulsout srf05,20         ' SEND A 10uS PULSE (.5 X 20) PIN STATE SHOULD END LOW
' THE SRF05 WILL SEND OUT AN ULTRASONIC PULSE THEN RAISE THE PIN HIGH
' ONCE AN ECHO IS DETECTED, THE PIN IS LOWERED ENDING THE TIMING PULSE
pulsin srf05, 0, range      ' MEASURE THE DURATION OF THE HIGH PULSE
range = range/74         ' DIVIDE BY SOMETHING TO GET AN UNDERSTANDABLE UNIT
Serout S_OUT, i9600, ["Range = ", dec range, " in", 13]
pause 500            ' PAUSE
goto main             ' GOTO BEGINNING OF LOOP


Don't get me wrong. I'm happy it seems to work like this but it seems to contradict how I understand the ultrasonic sensor is supposed to function in relation to the code.


Top
 Profile  
 
 Post subject: Re: AtomPro and Devantech SRF05 pulsin code question
PostPosted: Thu Aug 05, 2010 8:55 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 784
Location: Temecula, CA
The pulsin initial state indicates the IDLE state of the lin. S0 if you are looking for a high sided pulse the idle state is low(0), if you are looking for a low sided pulse the idle state is 1. I just looked at the code for pulsin and that is definitely how it works.

Pulsin waits until the I/O is at the idle state(upto the timeout time). If it sees that idle state it will then change to looking for the active state. It will wait for the active state up to the timeout time left. If it gets the active state it starts counting. If the active state switches back to the idle state within the timeout time left, the count is saved. If timeout time runs out in any of these three phases the command will return a 0 or jump to the error label if specified.

_________________
Nathan Scherdin
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: AtomPro and Devantech SRF05 pulsin code question
PostPosted: Thu Aug 05, 2010 10:46 am 
Offline
Citizen

Joined: Wed Aug 04, 2010 6:55 pm
Posts: 7
Location: Colorado
Nathan,

When you explain it that way it makes sense. I think the way it's explained in the programming manual it was confusing me. I will go back and look at the manual again with your explanation in mind. The other thing that was adding to the confusion was that the examples I could find were for Basic Stamp and all have that parameter set to 1. Do you know if Basic Stamp differs in the way it uses that pulsin parameter? Here's an example:

Quote:
Pulsin 4,0 measures an input pulse on pin 4 and starts measuring when a high-to-low transition occurs. Measurement stops when the next low-to-high transition is sensed.

By your definition, the idle state is high and we would need to flip that 0 value to 1 when using the BasicAtom Pro.

It's helpful to understand the subtle differences since the syntax is identical.


Top
 Profile  
 
 Post subject: Re: AtomPro and Devantech SRF05 pulsin code question
PostPosted: Thu Aug 05, 2010 4:13 pm 
Offline
Citizen

Joined: Wed Aug 04, 2010 6:55 pm
Posts: 7
Location: Colorado
OK. Hate to beat this horse but I just looked at the BasicATOM Pro syntax manual version 8.0 and it says:
Quote:
direction is a variable or constant (0 or 1) that specifies the pulse direction. If state = 0, the pulse must begin with a 1-to-0 transition. If state = 1 the pulse must begin with a 0-to-1 transition.
I'm sorry if I'm being completely dense on this because this seems to contradict what you are saying. What I think you are saying is that if state = 0, the pulse must begin with a 0-to-1 transition since, by your definition, the direction variable is set to the idle or initial state. This is exactly how it is behaving in my application (and is working) but opposite of every example I look at.

I really hate to keep coming back to this because it seems to be behaving exactly the opposite of how it is described across the board. Is it possible that it's somehow being compiled backwards? My main concern is that I am completely missing this very basic concept somehow and had hoped I was a little smarter than that - I could be fooling myself.


Top
 Profile  
 
 Post subject: Re: AtomPro and Devantech SRF05 pulsin code question
PostPosted: Thu Aug 05, 2010 4:44 pm 
Offline
Citizen

Joined: Wed Aug 04, 2010 6:55 pm
Posts: 7
Location: Colorado
BUG! It looks like this is a compiler bug. I also have a BasicATOM 28 pin. I swapped the chips - exact same board and setup. Now the code only works when the pulsin direction is set to 1 (as would be expected). It looks like it is somehow compiling that parameter for the Pro opposite of how it should be. I'm using the studio version 1.0.0.32. I will also try to send a bug report via the Studio interface.


Top
 Profile  
 
 Post subject: Re: AtomPro and Devantech SRF05 pulsin code question
PostPosted: Thu Aug 05, 2010 4:49 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 784
Location: Temecula, CA
Not a bug, but an implementation problem. I'll have to look at the new manual and make sure that both the Atom and AtomPro(they are completely different processors and libraries) use the same meaning for that argument.

_________________
Nathan Scherdin
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: AtomPro and Devantech SRF05 pulsin code question
PostPosted: Thu Aug 05, 2010 4:57 pm 
Offline
Citizen

Joined: Wed Aug 04, 2010 6:55 pm
Posts: 7
Location: Colorado
:lol: Sorry. Maybe I should have said it was driving me buggy. I'm always afraid I'm losing my mind and I frankly just don't have that much left to lose. Thanks for looking into that!


Top
 Profile  
 
 Post subject: Re: AtomPro and Devantech SRF05 pulsin code question
PostPosted: Fri Aug 13, 2010 12:52 pm 
Offline
Citizen

Joined: Wed Aug 04, 2010 6:55 pm
Posts: 7
Location: Colorado
Any word on this? As I had stated in my initial posts, it looks like the implementation of the pulsin syntax is not consistent between the Atom and AtomPro. While I understand they are very different animals, I think having this parameter function differently for each is confusing and the documentation for the Pro seems to reflect the opposite of what the compiler is producing.


Top
 Profile  
 
 Post subject: Re: AtomPro and Devantech SRF05 pulsin code question
PostPosted: Fri Aug 13, 2010 5:48 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 784
Location: Temecula, CA
Its in my todo list. :). Since there is a work around(eg flip the state setting) It's not got as high a priority as other reports. I expect to have it fixed in the next release though.

_________________
Nathan Scherdin
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: AtomPro and Devantech SRF05 pulsin code question
PostPosted: Fri Aug 13, 2010 5:54 pm 
Offline
Citizen

Joined: Wed Aug 04, 2010 6:55 pm
Posts: 7
Location: Colorado
Thank you very much! I'll look forward to it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO