Thread Subject: Send HEX Data

Subject: Send HEX Data

From: Rami AbouSleiman

Date: 27 May, 2008 03:49:01

Message: 1 of 5

hi,
I want to send hex data through serial port,
Any clue of how to do it?
Thanks

Subject: Send HEX Data

From: David

Date: 27 May, 2008 12:40:19

Message: 2 of 5

"Rami AbouSleiman" <rdabousl@oakland.edu> wrote in message
<g1g0bd$6ch$1@fred.mathworks.com>...
> hi,
> I want to send hex data through serial port,
> Any clue of how to do it?
> Thanks

'hex' is not a type of data, it is a way to represent data
in a user interface. a serial port sends streams of bits,
those bits can represent anything, what you need to
determine is what is the base data type and call the write
function for the port with the proper data type defined.

Subject: Send HEX Data

From: Rami AbouSleiman

Date: 27 May, 2008 13:32:29

Message: 3 of 5

"David " <dave@bigcompany.com> wrote in message
<g1gvfj$5qm$1@fred.mathworks.com>...
> "Rami AbouSleiman" <rdabousl@oakland.edu> wrote in
message
> <g1g0bd$6ch$1@fred.mathworks.com>...
> > hi,
> > I want to send hex data through serial port,
> > Any clue of how to do it?
> > Thanks
>
> 'hex' is not a type of data, it is a way to represent
data
> in a user interface. a serial port sends streams of
bits,
> those bits can represent anything, what you need to
> determine is what is the base data type and call the
write
> function for the port with the proper data type defined.

thanks for the post,
I have a gui slider and everytime i move it, it sends
values from 0 to 65535, i am using fwrite(obj1, num);
where num is the data to be send.
I get trash on the serial port, although I have on it a hex
and ascii hyperterminal.
even if i use dec2hex and send the hex value it also does
not work.
any clue?
Thanks

Subject: Send HEX Data

From: David

Date: 27 May, 2008 15:25:03

Message: 4 of 5

"Rami AbouSleiman" <rdabousl@oakland.edu> wrote in message
<g1h2hd$9t8$1@fred.mathworks.com>...
> "David " <dave@bigcompany.com> wrote in message
> <g1gvfj$5qm$1@fred.mathworks.com>...
> > "Rami AbouSleiman" <rdabousl@oakland.edu> wrote in
> message
> > <g1g0bd$6ch$1@fred.mathworks.com>...
> > > hi,
> > > I want to send hex data through serial port,
> > > Any clue of how to do it?
> > > Thanks
> >
> > 'hex' is not a type of data, it is a way to represent
> data
> > in a user interface. a serial port sends streams of
> bits,
> > those bits can represent anything, what you need to
> > determine is what is the base data type and call the
> write
> > function for the port with the proper data type
defined.
>
> thanks for the post,
> I have a gui slider and everytime i move it, it sends
> values from 0 to 65535, i am using fwrite(obj1, num);
> where num is the data to be send.
> I get trash on the serial port, although I have on it a
hex
> and ascii hyperterminal.
> even if i use dec2hex and send the hex value it also
does
> not work.
> any clue?
> Thanks


so you are trying to send a character representation of
the slider interger value. after you use dec2hex how do
you write that to the com port?

Subject: Send HEX Data

From: Rami AbouSleiman

Date: 27 May, 2008 15:39:01

Message: 5 of 5

"David " <dave@bigcompany.com> wrote in message
<g1h94f$7di$1@fred.mathworks.com>...
> "Rami AbouSleiman" <rdabousl@oakland.edu> wrote in
message
> <g1h2hd$9t8$1@fred.mathworks.com>...
> > "David " <dave@bigcompany.com> wrote in message
> > <g1gvfj$5qm$1@fred.mathworks.com>...
> > > "Rami AbouSleiman" <rdabousl@oakland.edu> wrote in
> > message
> > > <g1g0bd$6ch$1@fred.mathworks.com>...
> > > > hi,
> > > > I want to send hex data through serial port,
> > > > Any clue of how to do it?
> > > > Thanks
> > >
> > > 'hex' is not a type of data, it is a way to represent
> > data
> > > in a user interface. a serial port sends streams of
> > bits,
> > > those bits can represent anything, what you need to
> > > determine is what is the base data type and call the
> > write
> > > function for the port with the proper data type
> defined.
> >
> > thanks for the post,
> > I have a gui slider and everytime i move it, it sends
> > values from 0 to 65535, i am using fwrite(obj1, num);
> > where num is the data to be send.
> > I get trash on the serial port, although I have on it a
> hex
> > and ascii hyperterminal.
> > even if i use dec2hex and send the hex value it also
> does
> > not work.
> > any clue?
> > Thanks
>
>
> so you are trying to send a character representation of
> the slider interger value. after you use dec2hex how do
> you write that to the com port?
>

I need the hex value of the slider to be sent over the
serial in other words slider goes from 0 to 65535 and thus
my output data should go from 0 to FFFF.
if

num =1500; % 1500 = 5DC
fwrite(obj1, num);

and if

num =1500;
num =dec2hex(num);
fwrite(obj1, num);

Both are not working
 

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com