Bluetooth transmission of sensor data

Hitec robotics including ROBONOVA humanoid, HSR-8498HB servos, MR C-3024 Controllers and RoboBasic
2 postsPage 1 of 1
2 postsPage 1 of 1

Bluetooth transmission of sensor data

Post by doddsiedodds » Tue Dec 08, 2009 11:50 pm

Post by doddsiedodds
Tue Dec 08, 2009 11:50 pm

Hey guys,

I've been working on trying to get robonova to transmit the sensor data from the 2 axis accelerometer to my terminal on the PC with varying degrees of success. I'm taking the value of the sensor in as an INTEGER and so this complicated matters but i've managed to get something working, don't know if anyone is interested.

It's formatted so you can load up the captured transmitted data into excel or numbers etc and plot lovely graphs of your robonova's orientation over time!

Code: Select all


'------------- DECLARING VARIABLES ------------------'
DIM X AS INTEGER
DIM CurrentDigitUnits AS BYTE
DIM CurrentDigitTens AS BYTE
DIM CurrentDigitHundreds AS BYTE
DIM SendDigit AS BYTE
DIM CarriageReturn AS BYTE
DIM LineFeed AS BYTE
DIM Comma AS BYTE
DIM Space AS BYTE
DIM TXout AS BYTE
CarriageReturn = 13
LineFeed = 10
Space = " "
'-----------------------------------------------------------'



'------------ Transmission Subroutine----------------'

Transmission:

X = AD(0)
CurrentDigitHundreds = X / 100
SendDigit = 48 + CurrentDigitHundreds
ETX 4800, SendDigit
CurrentDigitTens = X / 10
CurrentDigitTens = CurrentDigitTens % 10
SendDigit  = 48 + CurrentDigitTens
ETX 4800, SendDigit
CurrentDigitUnits = X % 10
SendDigit  = 48 + CurrentDigitUnits
ETX 4800, SendDigit
ETX 4800, LineFeed
ETX 4800, CarriageReturn
GOSUB Transmission
END
'----------------------------------------------------'



I'm aware it looks a bit odd (I'm not taking the modulus of the hundreds digit for example) But it all works a-ok! Line feed and carriage return might result in a double spacing of lines depending on your terminal.

Doddsie
Hey guys,

I've been working on trying to get robonova to transmit the sensor data from the 2 axis accelerometer to my terminal on the PC with varying degrees of success. I'm taking the value of the sensor in as an INTEGER and so this complicated matters but i've managed to get something working, don't know if anyone is interested.

It's formatted so you can load up the captured transmitted data into excel or numbers etc and plot lovely graphs of your robonova's orientation over time!

Code: Select all


'------------- DECLARING VARIABLES ------------------'
DIM X AS INTEGER
DIM CurrentDigitUnits AS BYTE
DIM CurrentDigitTens AS BYTE
DIM CurrentDigitHundreds AS BYTE
DIM SendDigit AS BYTE
DIM CarriageReturn AS BYTE
DIM LineFeed AS BYTE
DIM Comma AS BYTE
DIM Space AS BYTE
DIM TXout AS BYTE
CarriageReturn = 13
LineFeed = 10
Space = " "
'-----------------------------------------------------------'



'------------ Transmission Subroutine----------------'

Transmission:

X = AD(0)
CurrentDigitHundreds = X / 100
SendDigit = 48 + CurrentDigitHundreds
ETX 4800, SendDigit
CurrentDigitTens = X / 10
CurrentDigitTens = CurrentDigitTens % 10
SendDigit  = 48 + CurrentDigitTens
ETX 4800, SendDigit
CurrentDigitUnits = X % 10
SendDigit  = 48 + CurrentDigitUnits
ETX 4800, SendDigit
ETX 4800, LineFeed
ETX 4800, CarriageReturn
GOSUB Transmission
END
'----------------------------------------------------'



I'm aware it looks a bit odd (I'm not taking the modulus of the hundreds digit for example) But it all works a-ok! Line feed and carriage return might result in a double spacing of lines depending on your terminal.

Doddsie
doddsiedodds offline
Robot Builder
Robot Builder
Posts: 12
Joined: Sun Dec 06, 2009 12:38 am

Post by doddsiedodds » Thu Dec 10, 2009 2:11 am

Post by doddsiedodds
Thu Dec 10, 2009 2:11 am

I've realised it might be possible to speed this up by instead transferring the 16 bit integer as 2 separate 8 bit integers by sending the integer first then the integer again after applying a right shift of 8 bits. Something like this:

Code: Select all
DIM X AS INTEGER
DIM XSHIFT AS INTEGER

X = AD(0)
ETX 4800, X
XSHIFT = X >> 8
ETX 4800, XSHIFT


This would reduce it down from 3 transmissions to 2 as well as requiring far less calculation (no need to work out each digit and convert to ascii) on the robot board itself but more on the receiving PC.

Not sure how i would go about coding the receiving end to perform the reverse and ANDing the high and low order bytes together - never done any programming using the serial port on a PC.
I've realised it might be possible to speed this up by instead transferring the 16 bit integer as 2 separate 8 bit integers by sending the integer first then the integer again after applying a right shift of 8 bits. Something like this:

Code: Select all
DIM X AS INTEGER
DIM XSHIFT AS INTEGER

X = AD(0)
ETX 4800, X
XSHIFT = X >> 8
ETX 4800, XSHIFT


This would reduce it down from 3 transmissions to 2 as well as requiring far less calculation (no need to work out each digit and convert to ascii) on the robot board itself but more on the receiving PC.

Not sure how i would go about coding the receiving end to perform the reverse and ANDing the high and low order bytes together - never done any programming using the serial port on a PC.
doddsiedodds offline
Robot Builder
Robot Builder
Posts: 12
Joined: Sun Dec 06, 2009 12:38 am


2 postsPage 1 of 1
2 postsPage 1 of 1
cron