CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

12bit transmit over RS232

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
pvol



Joined: 10 Oct 2008
Posts: 46
Location: GREECE

View user's profile Send private message

12bit transmit over RS232
PostPosted: Sun Oct 19, 2008 3:42 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Oct 19, 2008 3:56 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Oct 19, 2008 4:09 am     Reply with quote

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







PostPosted: Sun Oct 19, 2008 4:22 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Oct 19, 2008 4:35 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Oct 19, 2008 4:37 am     Reply with quote

You should use %lu respectively %ld printf format with CCS C to display int16 values.
pvol



Joined: 10 Oct 2008
Posts: 46
Location: GREECE

View user's profile Send private message

PostPosted: Sun Oct 19, 2008 4:50 am     Reply with quote

i'll try it and i'll tell you the results
thanks for the answers...
pvol



Joined: 10 Oct 2008
Posts: 46
Location: GREECE

View user's profile Send private message

PostPosted: Wed Oct 22, 2008 12:54 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Oct 22, 2008 1:09 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Oct 23, 2008 2:57 am     Reply with quote

thank you!!!
works great!! Very Happy Very Happy
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group