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.

Thursday, August 2, 2007

Re: [oopic] Re: Converting a string value to a numeric value?

thetruth_as_i_seeit wrote:
> --- In oopic@yahoogroups.com, Andrew Porrett <slicerwizard@...> wrote:
>
>> At 10:00 PM 8/1/2007, thetruth_as_i_seeit wrote:
>>
>>> I'm trying to receive data to my OOPic R through a serial port
>>> connected to a laptop. I want to use this data to control objects
>>>
>> >from the OOPic but, in order to do that, I need to convert the
>>
> string
>
>>> data that is coming from the serial port to numeric data.
>>>
>> It would help if you indicated exactly what "strings" you plan on
>> sending. I don't imagine you'll be sending single character
>>
> commands forever.
>
>>
>>> In C, there is a specific function for this called atoi, but I
>>>
> can't
>
>>> find anything like it in the OOPic manual.
>>>
>> There isn't anything like it. You'll have to roll your own.
>>
>>
>>
>>> Just in case anybody wants to see it, here is my code ...
>>>
>>> Dim A As New oDIO1
>>> Dim B as New oSerial
>>>
>>> Sub Main()
>>> A.IOLine = 8
>>> A.Direction = cvOutput
>>> B.Baud = cv9600
>>> B.Operate = cvTrue
>>> A = 0
>>> Do
>>> If B.Received = cvTrue then
>>> B.Value = B.value
>>>
>> I take it you're echoing the characters back to the PC here?
>>
>>
>>
>>> End If
>>> A = B
>>>
>> That will (sometimes) grab the NEXT character from the serial port
>> and put it in A.
>>
>>
>>
>>> Loop
>>> End Sub
>>>
>>> Obviously, this doesn't work because B is not a zero or one in a
>>> numerical sense, and what I am picking up is ASCI code ... in other
>>> words a whole bunch of zeros and ones.
>>>
>> You need to convert from ASCII characters to numeric values. You
>> need an atoi...
>>
>>
>>
>>> Any thoughts?
>>>
>> Sure. It looks like you want to send '0' or '1' to turn the DIO1
>>
> off or on.
>
>> a = 0
>> do
>> if b.received then
>> c = b // copy rcvd character to c (declare c as a byte
>>
> variable)
>
>> b = c // echo character back to PC
>>
>> // set a to zero or one
>>
>> a = c - 48 // '0' = ASCII code #48, '1' = ASCII code #49
>> end if
>> loop
>>
>>
>> You'll have to clean that up for whatever OOPic "language" you're
>> using (BASIC?)
>>
>> I imagine you'd like to do more than just toggle a single DIO1 - so
>> what's next?
>>
>>
>> ...Andy
>>
>>
>
>
> Thanks guys,
>
> Your answers were quite helpful. Believe it or not, I really DO just
> want to toggle a switch on and off via my PC LOL. In this case its a
> switch for a light on a moving object I'm trying to track. A webcam
> takes a picture with the light on and then off, and I use this
> information to track position, movement, etc. As long as the object
> moves slow enough, the oSerial object will work. Later on, I might
> have to get smarter (heaven forbid).
>
>

Using SCP you can send this string to the Oopic without having to use a
oSerial object:

\041J1N\A will switch the light ON
\041J0N\A will switch the light OFF

Where[\0] captures the USART port to receive SCP strings
Where [41J] is the address where A is positioned in the object list
on the Oopic
Where [1N] writes the value 1 to A
Where [0N] writes the value 0 to A
Where[\A] releases the USART port for other use.

Should you require to read the value of A then the following string will
return its value:

\041JM\A

Note that the address of the object is dependant on object type and
where it is positioned in your dimension list. Also for this to work all
you have to do is dimension A. No other code is required with respect to A.

If I may ask, what image processing software are you using? I use
RoboRealm with great success.


Ian



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/

[oopic] Re: Converting a string value to a numeric value?

--- In oopic@yahoogroups.com, Andrew Porrett <slicerwizard@...> wrote:
>
> At 10:00 PM 8/1/2007, thetruth_as_i_seeit wrote:
> >I'm trying to receive data to my OOPic R through a serial port
> >connected to a laptop. I want to use this data to control objects
> >from the OOPic but, in order to do that, I need to convert the
string
> >data that is coming from the serial port to numeric data.
>
> It would help if you indicated exactly what "strings" you plan on
> sending. I don't imagine you'll be sending single character
commands forever.
>
>
> >In C, there is a specific function for this called atoi, but I
can't
> >find anything like it in the OOPic manual.
>
> There isn't anything like it. You'll have to roll your own.
>
>
> >Just in case anybody wants to see it, here is my code ...
> >
> >Dim A As New oDIO1
> >Dim B as New oSerial
> >
> >Sub Main()
> > A.IOLine = 8
> > A.Direction = cvOutput
> > B.Baud = cv9600
> > B.Operate = cvTrue
> > A = 0
> > Do
> > If B.Received = cvTrue then
> > B.Value = B.value
>
> I take it you're echoing the characters back to the PC here?
>
>
> > End If
> > A = B
>
> That will (sometimes) grab the NEXT character from the serial port
> and put it in A.
>
>
> > Loop
> >End Sub
> >
> >Obviously, this doesn't work because B is not a zero or one in a
> >numerical sense, and what I am picking up is ASCI code ... in other
> >words a whole bunch of zeros and ones.
>
> You need to convert from ASCII characters to numeric values. You
> need an atoi...
>
>
> >Any thoughts?
>
> Sure. It looks like you want to send '0' or '1' to turn the DIO1
off or on.
>
> a = 0
> do
> if b.received then
> c = b // copy rcvd character to c (declare c as a byte
variable)
> b = c // echo character back to PC
>
> // set a to zero or one
>
> a = c - 48 // '0' = ASCII code #48, '1' = ASCII code #49
> end if
> loop
>
>
> You'll have to clean that up for whatever OOPic "language" you're
> using (BASIC?)
>
> I imagine you'd like to do more than just toggle a single DIO1 - so
> what's next?
>
>
> ...Andy
>


Thanks guys,

Your answers were quite helpful. Believe it or not, I really DO just
want to toggle a switch on and off via my PC LOL. In this case its a
switch for a light on a moving object I'm trying to track. A webcam
takes a picture with the light on and then off, and I use this
information to track position, movement, etc. As long as the object
moves slow enough, the oSerial object will work. Later on, I might
have to get smarter (heaven forbid).


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/

[oopic] Re: Converting a string value to a numeric value?

--- In oopic@yahoogroups.com, "thetruth_as_i_seeit" <lone_wolf@...> wrote:
>
> I'm trying to receive data to my OOPic R through a serial port
> connected to a laptop. I want to use this data to control objects
> from the OOPic but, in order to do that, I need to convert the string
> data that is coming from the serial port to numeric data.
>
> In C, there is a specific function for this called atoi, but I can't
> find anything like it in the OOPic manual.
>
> Just in case anybody wants to see it, here is my code ...
>
> Dim A As New oDIO1
> Dim B as New oSerial
>
> Sub Main()
> A.IOLine = 8
> A.Direction = cvOutput
> B.Baud = cv9600
> B.Operate = cvTrue
> A = 0
> Do
> If B.Received = cvTrue then
> B.Value = B.value
> End If
> A = B
> Loop
> End Sub
>
> Obviously, this doesn't work because B is not a zero or one in a
> numerical sense, and what I am picking up is ASCI code ... in other
> words a whole bunch of zeros and ones.
>
> Any thoughts?
>

Two thoughts: you REALLY want to use oSerialPort instead of oSerial.
This will give you a 4 byte receive buffer that you WILL need.

Second, you should plan to use SCP (chapter 16 of manual) for a couple
of reasons: First, it is pretty flexible in allowing you to change the
properties of objects and second because it OOPic can process the data
much faster internally than you can with a loop in code. Loop code is
just a poor way to use the OOPic.

A final thought: the OOPic just doesn't handle serial input very well.
Even with oSerialPort, the buffer is too small.

Richard



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/

Re: [oopic] Converting a string value to a numeric value?

At 10:00 PM 8/1/2007, thetruth_as_i_seeit wrote:
>I'm trying to receive data to my OOPic R through a serial port
>connected to a laptop. I want to use this data to control objects
>from the OOPic but, in order to do that, I need to convert the string
>data that is coming from the serial port to numeric data.

It would help if you indicated exactly what "strings" you plan on
sending. I don't imagine you'll be sending single character commands forever.


>In C, there is a specific function for this called atoi, but I can't
>find anything like it in the OOPic manual.

There isn't anything like it. You'll have to roll your own.


>Just in case anybody wants to see it, here is my code ...
>
>Dim A As New oDIO1
>Dim B as New oSerial
>
>Sub Main()
> A.IOLine = 8
> A.Direction = cvOutput
> B.Baud = cv9600
> B.Operate = cvTrue
> A = 0
> Do
> If B.Received = cvTrue then
> B.Value = B.value

I take it you're echoing the characters back to the PC here?


> End If
> A = B

That will (sometimes) grab the NEXT character from the serial port
and put it in A.


> Loop
>End Sub
>
>Obviously, this doesn't work because B is not a zero or one in a
>numerical sense, and what I am picking up is ASCI code ... in other
>words a whole bunch of zeros and ones.

You need to convert from ASCII characters to numeric values. You
need an atoi...


>Any thoughts?

Sure. It looks like you want to send '0' or '1' to turn the DIO1 off or on.

a = 0
do
if b.received then
c = b // copy rcvd character to c (declare c as a byte variable)
b = c // echo character back to PC

// set a to zero or one

a = c - 48 // '0' = ASCII code #48, '1' = ASCII code #49
end if
loop


You'll have to clean that up for whatever OOPic "language" you're
using (BASIC?)

I imagine you'd like to do more than just toggle a single DIO1 - so
what's next?


...Andy



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/

Wednesday, August 1, 2007

Re: [oopic] Converting a string value to a numeric value?

thetruth_as_i_seeit wrote:
> I'm trying to receive data to my OOPic R through a serial port
> connected to a laptop. I want to use this data to control objects
> from the OOPic but, in order to do that, I need to convert the string
> data that is coming from the serial port to numeric data.
>
> In C, there is a specific function for this called atoi, but I can't
> find anything like it in the OOPic manual.
>
> Just in case anybody wants to see it, here is my code ...
>
> Dim A As New oDIO1
> Dim B as New oSerial
>
> Sub Main()
> A.IOLine = 8
> A.Direction = cvOutput
> B.Baud = cv9600
> B.Operate = cvTrue
> A = 0
> Do
> If B.Received = cvTrue then
> B.Value = B.value
> End If
> A = B
> Loop
> End Sub
>
> Obviously, this doesn't work because B is not a zero or one in a
> numerical sense, and what I am picking up is ASCI code ... in other
> words a whole bunch of zeros and ones.
>
> Any thoughts?
>
>
>
>
>

I am assuming the value you are receiving with the oSerial object is an
ascii value. In which case the zero value that you sent from the PC will
be received as ascii 48

You could do this with a select case construct for example:-

Select Case B

Case 48: A = 0

Case 49: A =1

end select

or alternately:-

If B = 48 then A = 0
If B= 49 then A = 1


However the most effective way to communicate with the Oopic is by using
SCP commands. Read Chapter 16 of the manual for details.
With SCP you can write/read data to/from any object directly without
having any code resident on the Oopic.

Regards

Ian



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/

[oopic] Converting a string value to a numeric value?

I'm trying to receive data to my OOPic R through a serial port
connected to a laptop. I want to use this data to control objects
from the OOPic but, in order to do that, I need to convert the string
data that is coming from the serial port to numeric data.

In C, there is a specific function for this called atoi, but I can't
find anything like it in the OOPic manual.

Just in case anybody wants to see it, here is my code ...

Dim A As New oDIO1
Dim B as New oSerial

Sub Main()
A.IOLine = 8
A.Direction = cvOutput
B.Baud = cv9600
B.Operate = cvTrue
A = 0
Do
If B.Received = cvTrue then
B.Value = B.value
End If
A = B
Loop
End Sub

Obviously, this doesn't work because B is not a zero or one in a
numerical sense, and what I am picking up is ASCI code ... in other
words a whole bunch of zeros and ones.

Any thoughts?


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/

[oopic] Wireless modules and OOPic

Hi Dan / Dennis

Thanks for the replies.

I needed either the WCM+ or FWCM as I already have both of these
units running on telemetry systems with OOPic II's and need to expand
the networks. As they have I2C interfaces they don't tie up the
serial comms on the OOPic which is ideal for our apps. and we also
use the on-board ADC lines to monitor a couple of thermistors for
temperature readings.

Luckily after searching both yahoo and google I found the
manufacturer (Totalrobots must buy these from this company)
using 'FWCM wireless', here is the link for anyone interested:

http://www.designergeneric.co.uk/designer/DS-FWCM_info.htm

Unfortunately they have disconntinued the WCM+ so we are going to
have to replace all of these with FWCM's:(

The Xbee based units look pretty good for most short range apps. but
are no good to me as their TX power @ 215mA is way to high for our
small battery based apps. We have also generally had problems testing
other 2.4GHz based systems in our networks.

These Designer Systems guys also do the GPS module I was asking
about. Its called the DS-GPM and has an I2C interface connection.
This unit would have been good for the guy trying to use the Parallex
GPS unit posted in April. I have a project coming up that will again
be OOPic based and will try out this GPS unit and report back with
any comments.

Having searched through the OOPic group I have found both the GPM and
FWCM mentioned a number of times so I guess there must be a few out
there.

Lloyd


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/