This Forum is Dedicated For all The Object Oriented PIC Lovers .......... The concept behind OOPic is straight forward. Use preprogrammed multitasking Objects from a library of highly optimized Objects to do all the work of interacting with the hardware. Then write small scripts in Basic, C, or Java syntax styles to control the Objects. During operation, the Objects run continuously and simultaneously in the background while the scripts run in the foreground telling the objects what to do.

Friday, November 30, 2007

Re: [oopic] Serial communication with negative values

Hi Aaron,
When I have a number that I want to transmit, and I know that is can
be negative, I just do a if statement to check if the number is less
then zero. If the number is less than zero then I divide the number by
-1 before I send the data.

Example :

If Number < 0 then
Serial.String = Str$(Number / -1)
else
Serial.String = Str$(Number)
EndIf

-Kit

On Nov 29, 2007 11:55 PM, a_k_townsend <a_k_townsend@yahoo.com> wrote:
> I have an OOPic-R (v5 compiler) communicating with my computer via
> the serial port for debugging. All variable types appear with
> leading zeros to make 5 digits (ie a value 1 appears as 00001), but
> that's fine. The problem occurs when a signed variable with a
> negative value is transmitted. The signed value shows up as
> (seemingly) random ASCII characters. As an example, a word with
> value -29536 appears as ".'+-*" (quotation marks added). Positive
> values of signed variables appear correctly. I can solve the problem
> by creating a second variable and assigning it the value of the first
> plus 32768, 128, or 8 (for word, byte, or nibble variables,
> respectively), to make the second variable always have a positive
> value. But then I have twice as many variables, more instructions to
> execute, and I have to subtract the same values off the value on the
> receiving end of the communication. Has anyone had this problem, or
> know of a more elegant way to solve it?
>
> Thank you,
> Aaron
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>



Yahoo! Groups Links

<*> To visit your group on the web, go to:

http://groups.yahoo.com/group/oopic/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:

http://groups.yahoo.com/group/oopic/join

(Yahoo! ID required)

<*> To change settings via email:
mailto:oopic-digest@yahoogroups.com
mailto:oopic-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
oopic-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:

http://docs.yahoo.com/info/terms/

No comments: