propeller get the sensor data showin the C# ?
ggg558877
Posts: 40
Hello everyone,
i have used a propeller C3 get the sensor data,
http://i1162.photobucket.com/albums/q535/ggg558877/1_zps95366eda.jpg,
and now i want to show the data in the c#
i have no idea what to do , is there any examples?
thanks
i have used a propeller C3 get the sensor data,
http://i1162.photobucket.com/albums/q535/ggg558877/1_zps95366eda.jpg,
and now i want to show the data in the c#
i have no idea what to do , is there any examples?
thanks
Comments
Open source C# serial terminal. Not the greatest but it works and it contains a few good nuggets.
Nice to meet you, Mike
now i use a simple example to run in the Parallax-Serial-Terminal,enter any number and it can calculate tangent
http://i1162.photobucket.com/albums/q535/ggg558877/789.jpg (sorry i don't know how to paste propeller code)
http://i1162.photobucket.com/albums/q535/ggg558877/555.jpg
and how can i get the same result in C# serial terminal
thanks
Other than that, enter values in the top textbox and click the send button.
What is your goal? To learn Spin and C#?
Hi, Mike
My goal just like this video
http://www.youtube.com/watch?feature=player_embedded&v=JJ1SBgGG11g
i already get the sensor(AHRS) data in Spin ,and now i want to use C# to receive those data
but i don't know how to send those data to C#
sorry this my first to do this
maybe it's a stupid question
My GroundStation program does all of this, and it's written in C#. You can download it from the top of this thread:
http://forums.parallax.com/showthread.php?136787-QuadX-my-latest-Propeller-with-Propellers
The MainForm_Load() function finds all the connected serial ports, picks the one it figures is the connected Propeller chip, and opens it.
The function GetCommWord() reads two bytes from the serial port and assembles them into a signed short (16 bit) value.
If you've never used C# before it might be a little overwhelming, but hopefully it's a step in the right direction.
Jason
now I get a new problem
I want to send a number from c# to propeller to control the servo and my send buttom code is and propeller code is
now I send a number 88000 and the propeller tx LED had Blinking but servo have not action
Can someone please tell me what is my problem
On the propeller side you must read the 5 bytes and convert the byte array into a number.
The DecIn command expects the number to terminate with a CR. So add a $13 to the end of txtDatasend.text
You can also send 88000 as a number. 88000 is 3 bytes $01, $57, $C0. On the Propeller side you'll assemble the bytes into a long.
how can i read the 5 bytes and convert the byte array into a number on the propeller side
can you give me some example?
thanks
Then, send that integer as 4 bytes, like this:
On the Propeller side, just read the 4 raw bytes out of the stream and reassemble them, like this:
The shifting (<< and >>) is to move the bits around. The first shift slides the upper 8 bits down so they're in the low 8-bit position, and then casting to a byte chops off the rest of the number. The other shifts select each subsequent set of 8 bits. On the Propeller side, you receive each set of 8 bits and use the opposite shifts to move them back into the right place, then use the or operator ( | ) to put them back together into a single variable.
hi,Jason
I try this code but he say can't convert string from byte
and I try this code i set a breakpoint and see the buffer is 0 ,1, 87, 192 when i give the value 88000
but servo isn't action too
how can i solve this problem?
thanks
propeller code
C# Code
Spin Source
but i have a new problem
in first time i send 88000 to propeller and servo go clockwise position
now i want servo to go counterclockwise position so i send 152000 to propeller
but servo still go clockwise position
how can i improve in the propeller code
and if i want to use two servo i use two hScrollBar to send the value
how can propeller Identification which value is servo1 and servo2
i want to do just like previous theme
http://forums.parallax.com/showthread.php?96973-VB-Express-to-Stamp-Template&highlight=Twin+Servo+Control
#8
thanks
Along with the servo position value, send the servo ID. You'll have to think about this and come up with a standard protocol so the Propeller and PC can decipher the data sent on the serial port.
Here's an idea:
![ID][Value][$0D]
The ServoSlider project goes with the ReceivePacket.spin. Sorry, it does not move a servo. It only blinks LEDs according to the track bar position. I'll leave the servo stuff up to you.
The SerialForm is the same project as posted on #12 and it goes with the spin code posted in the same post.
Have fun
I have a problem
now i use ServoSlider project to change the LED blink speed
and if value not change the LED keep this speed blinking
if value change LED blinking on the new speed
so i add this code i try it
sometime it success but sometime it have problem
sometime i change the value LED keep bright or not bright
can anyone give me some suggest?
The payload is in little endian which means the least significant byte is sent first.
The spin code is simply disassembling the packet. First, the spin code looks for a "!". The next byte is the ID followed by the length of the payload, and ending with an $0D.
This code block disassembles the command.
Here's one way to change the blink rate. Add an parameter to the Toggle method and fix the number of times the LED blinks. The default program was setup to blink an LED 1 to 10 times depending on the trackbar position.
i think i have already understand what you say
in your propeler code you blink an LED 1 to 10 times
but now i want it blink in the same rate until the new command receive
and it will blink in the new rate
so i change to is it not right?
This is a sample of the source. The entire source can be found in post 15
This type of information is also available in the Propeller Education Kit. From the Propeller tool click Help -> select Propeller Education kit.
use this method my servo problem also can be solve
but it have to use 2 cog to control 1 servo
one to produce PWM ,one to control the servo's position
if i just want use 1 cog to control servo
do you have any suggest?
thanks
i have a new problem
i get the sensor data and now i want the value length is same
for example
100=100 , 10=010 , 1=001 how can i change my code?
and is there some easier example for propeller tx and C# serialport.read?
thanks
now i want to send a command to C# to read the data value
and the command just like !yaw|pitch|roll0D
or is that right?
I do not know. Do you still require ASCII encoded zero padded 3 digit numbers? If so, then your example is NOT correct. Plus it appears that we're going from PST to FDS???
sorry what's the FDS mean?
thanks
Your requirements are not clear and change from post to post.
If the requirement is to send pitch, roll, and yaw and the values do not exceed 0XFFFF (65,535) then I would send the following packet.
! [command] [low byte] [high byte] [CR]
Where command is a number that represents pitch, roll, or yaw.
pitch = 1
roll = 2
yaw = 3
IMO, this packet format makes framing the packets on the PC side a little easier. However, it might not be the best method. You need to solidify the project requirements.