Realbasic to PSC help please
CJ
Posts: 470
Hello, and thank you for checking this post.
I am trying to get my programs to talk to the PSC, but am having trouble getting the integers in my program
into a coherent dataset that the PSC can understand.
my integers are defined as
pulse as unsigned 16bit
ramp as unsigned 8bit
channel as unsigned 8bit
aparently the serial port will only accept strings,
so, how to convert bytes to characters and how to send the pulse bytes in the correct order?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who says you have to have knowledge to use it?
I've killed a fly with my bare mind.
I am trying to get my programs to talk to the PSC, but am having trouble getting the integers in my program
into a coherent dataset that the PSC can understand.
my integers are defined as
pulse as unsigned 16bit
ramp as unsigned 8bit
channel as unsigned 8bit
aparently the serial port will only accept strings,
so, how to convert bytes to characters and how to send the pulse bytes in the correct order?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who says you have to have knowledge to use it?
I've killed a fly with my bare mind.
Comments
· portStr = Chr(servoPos Mod 256) & Chr(servoPos \ 256)
This is low-byte, then high-byte.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who says you have to have knowledge to use it?
I've killed a fly with my bare mind.
Unfortunately, it's a one-way (BS1-to-PC) deal; unlike the BS2, the BS1 cannot take serial data from its programming port.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
no offence but, have you thought of using a graphical representation for the pin values as well? kinda like the memory map in the editor or even just
binary representation
trying to extract bit values makes my head hurt
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who says you have to have knowledge to use it?
I've killed a fly with my bare mind.
And in case you're interested, here's the code that converts a value to a binary string:
Private Function BinStr(value As Long, width As Byte) As String
· Dim idx As Byte
· Dim testBit As Long
· Dim tmpBin As String
·
· testBit = 2 ^ width
· value = value Mod testBit
· tmpBin = "%"
· For idx = 1 To width
··· testBit = testBit·\ 2
··· If (value >= testBit) Then
····· tmpBin = tmpBin & "1"
····· value = value - testBit
··· Else
····· tmpBin = tmpBin & "0"
··· End If
· Next
· BinStr = tmpBin
End Function
Please note that I don't claim to be a great VB programmer -- I just make simple programs that work.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 1/17/2006 10:11:29 PM GMT
You are truly a master at this stuff.
In addtition to your fantastic knowledge, all your articles are very well written and easy to understand as well.
When I grow up, I want to be just like you.·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
·
Here's the end target of that exercise -- I wanted to use the BS1-USB as a front-end for a PC program.· In my case I made it very easy by attaching a DS1620 to the BS1-USB (I'll upload a photo when the camera battery is charged).· It turns out the VB integers "understand" BASIC Stamp negative numbers so there is nothing tricky at all about the VB code: just capture, covert to degrees C (by dividing by 2), then convert to F.· After I got the DEBUG stream capture licked the rest was very easy.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 1/18/2006 1:07:58 AM GMT