BS2 Functions Library
Martin Hebel
Posts: 1,239
This my completed (hopefully) library performing many of the functions of a BS2, plus some with my own 'spin'.
It also includes a sample program running various functions in different cogs, and a watch-dog cog to ensure another cog doesn't get hung-up waiting forever for a PULSIN that never arrives.
-Martin
Post Edited (Martin Hebel) : 3/20/2006 11:40:55 PM GMT
It also includes a sample program running various functions in different cogs, and a watch-dog cog to ensure another cog doesn't get hung-up waiting forever for a PULSIN that never arrives.
-Martin
Post Edited (Martin Hebel) : 3/20/2006 11:40:55 PM GMT
Comments
It's 100% spin making it easier to modify it as you like. My proudest achievments were using the cog counter for a COUNT and being able to accept an ASCII string, such as "abc123". This will really be helpful fhow those who need to get serial data from a device as a string, such as GPS units, to easily parse it. But, being in Spin, there wasn't time to perform loops for timeout, so it will wait forever, such as in PULSIN or SERIN, thus the use of the WatchDog Cog in the example.
-Martin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
Perform an Employer's Survey of Electronic Technologies Graduates· - Click here!
Personal Links with plenty of BASIC Stamp info
and SelmaWare Solutions - StampPlot - Graphical Data Acquisition and Control
Post Edited (Martin Hebel) : 3/21/2006 5:39:31 AM GMT
-Martin
· duration := ||(clkStop - clkStart) * 1000
?
BTW, I think it's very cool that you've created this library and it should make porting BASIC Stamp projects a lot of fun.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
I was thinking the math would take care of itself, but that probably only works for waitcnt. I'll try to force a rollover and see what happens. || is the absolute function? Glad you told me [noparse]:)[/noparse] There's several other functions/methods where this would be an issue.
I hope it helps!
Thanks,
Martin
Jon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
Perform an Employer's Survey of Electronic Technologies Graduates· - Click here!
Personal Links with plenty of BASIC Stamp info
and SelmaWare Solutions - StampPlot - Graphical Data Acquisition and Control
-Martin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
Perform an Employer's Survey of Electronic Technologies Graduates· - Click here!
Personal Links with plenty of BASIC Stamp info
and SelmaWare Solutions - StampPlot - Graphical Data Acquisition and Control
I had forgotten about the absolute operator.... RCTIME probably needs the absolute operator as well
as the 32SERVO, although I did take some consideration to roll-over within the 32SERVO method.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Start: 777869
Stop: 803805
Dur in uS = 324
Waiting for the counter to wind up:
Start: -22997
Stop: 2827
Dur in uS = 322
2827 -(-22997) = +25724 /80 =322
Looks like with even counter wrap around, the math works out.
Even high in the negatives, it works fine. 2's compliment at it best:
Start: -1046988
Stop : -1020988
Dur in uS = 325
Ok, but I will admit my RCTime code is hosed. I made it too convoluted... it was one of the earlier ones I tried. With higher RC values, I was getting negative numbers, but I think it was my after-math than counter issues. I'll just keep the duration in 1uS units.
I'll repost with new code after a few other tweaks.
Thanks for making me take a closer look Jon.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
Southern Illinois University Carbondale - Electronic Systems Technologies
Personal Links with plenty of BASIC Stamp info
StampPlot - Graphical Data Acquisition and Control
Post Edited (Martin Hebel) : 3/23/2006 3:46:22 AM GMT