View previous topic :: View next topic |
Author |
Message |
pvol
Joined: 10 Oct 2008 Posts: 46 Location: GREECE
|
12bit transmit over RS232 |
Posted: Sun Oct 19, 2008 3:42 am |
|
|
hello...
i need to transmit 12bit value over 232
how can i do this?
232 has 8bit data
one thought is to split 12bit in 2 bytes and transfer it separately.
but its very difficulty to join them at the pc (i use labview )
is there a simple way to do this?
thank you.. |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sun Oct 19, 2008 3:56 am |
|
|
That's exclusively a LabView problem to my opinion. But why not sending the data decimal or hex coded? |
|
|
pvol
Joined: 10 Oct 2008 Posts: 46 Location: GREECE
|
|
Posted: Sun Oct 19, 2008 4:09 am |
|
|
can i send a number >255 ?
let's say, as example that
i write printf("500\n");
what value will send to pc? |
|
|
Ttelmah Guest
|
|
Posted: Sun Oct 19, 2008 4:22 am |
|
|
Printf, as you show there, sends _text_. Nothing whatsovever to stop you sending (for instance) '25000', but over the RS232, this will be sent as five ASCII text characters, not '12 bits'. This is probably the easiest way to do what you want, but will take more time over the RS232.
Best Wishes |
|
|
pvol
Joined: 10 Oct 2008 Posts: 46 Location: GREECE
|
|
Posted: Sun Oct 19, 2008 4:35 am |
|
|
in order to send '25000' what must i do so that the computer understands 25000 as a number and not as characters?
what kind of transformation must i do at the CCS? |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sun Oct 19, 2008 4:37 am |
|
|
You should use %lu respectively %ld printf format with CCS C to display int16 values. |
|
|
pvol
Joined: 10 Oct 2008 Posts: 46 Location: GREECE
|
|
Posted: Sun Oct 19, 2008 4:50 am |
|
|
i'll try it and i'll tell you the results
thanks for the answers... |
|
|
pvol
Joined: 10 Oct 2008 Posts: 46 Location: GREECE
|
|
Posted: Wed Oct 22, 2008 12:54 am |
|
|
i tried this and works fine!!
now i have another problem
i want to present an array that has got negative numbers on labview
int array[6]={10 20 30 -10 -20 -30}
for (i=1;i<=6,i++)
{printf("u% \n"array[i])}
10 20 30 plotted
but -10 -20 -30 not!
what is your opinion about this?
is it possible to sent (and present) negative numbers? |
|
|
Salenko
Joined: 08 Sep 2008 Posts: 84
|
|
Posted: Wed Oct 22, 2008 1:09 am |
|
|
pvol wrote: | i tried this and works fine!!
now i have another problem
i want to present an array that has got negative numbers on labview
int array[6]={10 20 30 -10 -20 -30}
for (i=1;i<=6,i++)
{printf("u% \n"array[i])}
10 20 30 plotted
but -10 -20 -30 not!
what is your opinion about this?
is it possible to sent (and present) negative numbers? |
Hello,
I think you should use signed int format: %d |
|
|
pvol
Joined: 10 Oct 2008 Posts: 46 Location: GREECE
|
|
Posted: Thu Oct 23, 2008 2:57 am |
|
|
thank you!!!
works great!! |
|
|
|