splitting a 16 bit number to two bytes
Hi there
I"m a bit new to number manipulation with max.
For a project I work on I need to send 16 bit numbers to the miscorcontroller I"m working with via the serial port. Yet the microcontroller I work with (a very basic one) can recieve through its hardware serial input only bytes (8 bit). So I need to split the 16 bit numbers into 2 halves - for instance - if I want to send the number 500 - or in binary -
0000000111110100
I need to send
11110100
and than
00000001
Can anyone suggest a way of doing it with max ?
cheers
Guy
i think this is what you're looking for, not sure :)
Thanks for that...
yet I"m very new to prgramming with max and dont really know what do to with this block of text that you sent me - do I need to compile it somehow ?
how do I use this patch that you sent me
cheers
Guy
just copy all of it, including the "-----begin" etc..., to "-----end", with all the dashes, then in Max 5, choose New From Clipboard. voila! :)
Thanks so much...
Is there any chance that it will owrk on Max 4.5 ?
thanks again for you help
Guy
Quote: guyba@cyllene.uwa.edu.au wrote on Sun, 05 October 2008 11:12
----------------------------------------------------
> Thanks so much...
> Is there any chance that it will owrk on Max 4.5 ?
The patch seejayjames gave you is Max 5 only.
Since it is only a few objects I quickly redid it in Max 4 for you. Exact same patch, just different format. Good luck.
Klaas-Jan Govaart schrieb:
> Quote: guyba@cyllene.uwa.edu.au wrote on Sun, 05 October 2008 11:12
> ----------------------------------------------------
>> Thanks so much... Is there any chance that it will owrk on Max 4.5
>> ?
>
> The patch seejayjames gave you is Max 5 only. Since it is only a few
> objects I quickly redid it in Max 4. For you. Exact same patch, just
> different format. Good luck.
Though this patch works, I'd actually use bitwise operations in this
case: replace the [/ 256] with [>> 8] and the [% 256] with [& 255]. Both
are magnitudes faster than / and %. Though this probably doesn't matter
at all with the speed of recent processors, it is closer to the bitwise
nature of the problem...
Stefan
--
Stefan Tiedje------------x-------
--_____-----------|--------------
--(_|_ ----|-----|-----()-------
-- _|_)----|-----()--------------
----------()--------www.ccmix.com
...and with just one object: [sxformat is $i1>>7 / is $i1 & 127]
_
johan