Help with OO code - Mike Martin - Jul 15 8:39:59 2008
Would anyone be kind enough to tell me where I'm going wrong here
please? I'm trying to write OO code to link a potentiometer to a
servo to make it change its position. I can do it with procedural
code OK but don't know what object to use in order to make it work
with OO. Info about linking is a little thin - I need a link to a
really good explaination to read about objects, pointers and flags if
any has one?
TIA
Mike M.
'Positions a servo using the .position of an
'oKnob Object (trim pot)
Dim Srv As New oServo 'Make a servo object.
Dim Pot As New oKnob 'Make a knob object
Dim Wire As New oWire
Sub main()
ooPIC.Node = 1
Call Setup
End Sub
Sub Setup() 'Setup servo properties
Srv.IOLine = 31 'set the servo to use I/O Line 31
Srv.Adjust = 28 'set the servos center to 28
Srv.Operate =cvTrue 'turn the Servo on
Pot.IOLine = 1 'IOLine 1, pin 7
Pot.Operate = cvTrue 'turn on IOLine 1
Wire.Input.Link(Pot.Value)
Wire.Output.Link(Srv.Position)
End Sub
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )
Re: Help with OO code - rtstofer - Jul 15 9:39:34 2008
--- In o...@yahoogroups.com, "Mike Martin"
wrote:
>
> Would anyone be kind enough to tell me where I'm going wrong here
> please? I'm trying to write OO code to link a potentiometer to a
> servo to make it change its position. I can do it with procedural
> code OK but don't know what object to use in order to make it work
> with OO. Info about linking is a little thin - I need a link to a
> really good explaination to read about objects, pointers and flags if
> any has one?
> TIA
> Mike M.
>
> 'Positions a servo using the .position of an
> 'oKnob Object (trim pot)
> Dim Srv As New oServo 'Make a servo object.
> Dim Pot As New oKnob 'Make a knob object
> Dim Wire As New oWire
>
> Sub main()
> ooPIC.Node = 1
> Call Setup
> End Sub
>
> Sub Setup() 'Setup servo properties
> Srv.IOLine = 31 'set the servo to use I/O Line 31
> Srv.Adjust = 28 'set the servos center to 28
> Srv.Operate =cvTrue 'turn the Servo on
> Pot.IOLine = 1 'IOLine 1, pin 7
> Pot.Operate = cvTrue 'turn on IOLine 1
> Wire.Input.Link(Pot.Value)
> Wire.Output.Link(Srv.Position)
> End Sub
>
I know I have made this work before but I'm not on the Windows box at
the moment.
We know the oKnob will output 0..255 but oKnobX will output -128..127.
We also know that oServoX operates with signed values of -64..63 but
will accept -128..127.
So, why not try oKnobX and oServoX?
Richard
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )Re: Re: Help with OO code - Ian Drennan - Jul 15 10:49:05 2008
Mike
In your setup routine you need to switch Wire on with the line:
wire.operate = cvOn
Ian
rtstofer wrote:
> --- In o...@yahoogroups.com, "Mike Martin"
wrote:
>
>> Would anyone be kind enough to tell me where I'm going wrong here
>> please? I'm trying to write OO code to link a potentiometer to a
>> servo to make it change its position. I can do it with procedural
>> code OK but don't know what object to use in order to make it work
>> with OO. Info about linking is a little thin - I need a link to a
>> really good explaination to read about objects, pointers and flags if
>> any has one?
>> TIA
>> Mike M.
>>
>> 'Positions a servo using the .position of an
>> 'oKnob Object (trim pot)
>> Dim Srv As New oServo 'Make a servo object.
>> Dim Pot As New oKnob 'Make a knob object
>> Dim Wire As New oWire
>>
>> Sub main()
>> ooPIC.Node = 1
>> Call Setup
>> End Sub
>>
>> Sub Setup() 'Setup servo properties
>> Srv.IOLine = 31 'set the servo to use I/O Line 31
>> Srv.Adjust = 28 'set the servos center to 28
>> Srv.Operate =cvTrue 'turn the Servo on
>> Pot.IOLine = 1 'IOLine 1, pin 7
>> Pot.Operate = cvTrue 'turn on IOLine 1
>> Wire.Input.Link(Pot.Value)
>> Wire.Output.Link(Srv.Position)
>> End Sub
>>
>>
>
> I know I have made this work before but I'm not on the Windows box at
> the moment.
>
> We know the oKnob will output 0..255 but oKnobX will output -128..127.
> We also know that oServoX operates with signed values of -64..63 but
> will accept -128..127.
>
> So, why not try oKnobX and oServoX?
>
> Richard
>
> ------------------------------------
>
>
[Non-text portions of this message have been removed]
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )Re: Help with OO code - Mike Martin - Jul 16 8:50:44 2008
Thanks Richard, but the *X objects don't work either. It has more to
do with the default property of the object I think because linking it
to what I thought was obvious kicks up an error that reads "Expecting
an oLogic Object or an object with the default property of oLogic"
but I don't have enough experience to pick the right one (?) or I
don't understand it well enought yet.
--- In o...@yahoogroups.com, "rtstofer"
wrote:
>
> --- In o...@yahoogroups.com, "Mike Martin" wrote:
> >
> > Would anyone be kind enough to tell me where I'm going wrong here
> > please? I'm trying to write OO code to link a potentiometer to a
> > servo to make it change its position. I can do it with procedural
> > code OK but don't know what object to use in order to make it
work
> > with OO. Info about linking is a little thin - I need a link to a
> > really good explaination to read about objects, pointers and
flags if
> > any has one?
> > TIA
> > Mike M.
> >
> > 'Positions a servo using the .position of an
> > 'oKnob Object (trim pot)
> > Dim Srv As New oServo 'Make a servo object.
> > Dim Pot As New oKnob 'Make a knob object
> > Dim Wire As New oWire
> >
> > Sub main()
> > ooPIC.Node = 1
> > Call Setup
> > End Sub
> >
> > Sub Setup() 'Setup servo properties
> > Srv.IOLine = 31 'set the servo to use I/O Line 31
> > Srv.Adjust = 28 'set the servos center to 28
> > Srv.Operate =cvTrue 'turn the Servo on
> > Pot.IOLine = 1 'IOLine 1, pin 7
> > Pot.Operate = cvTrue 'turn on IOLine 1
> > Wire.Input.Link(Pot.Value)
> > Wire.Output.Link(Srv.Position)
> > End Sub
> > I know I have made this work before but I'm not on the Windows box
at
> the moment.
>
> We know the oKnob will output 0..255 but oKnobX will output -
128..127.
> We also know that oServoX operates with signed values of -64..63
but
> will accept -128..127.
>
> So, why not try oKnobX and oServoX?
>
> Richard
>
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )Re: Help with OO code - Mike Martin - Jul 16 8:52:14 2008
Thanks Ian. Still can't figure it out though. Dennis' book clearly
states (p. 64) that all hardware objects have a value property and
that the value property is referenced by default when you link its
output to the input of another. So back to the manual...
--- In o...@yahoogroups.com, Ian Drennan
wrote:
>
> Mike
>
> In your setup routine you need to switch Wire on with the line:
> wire.operate = cvOn
>
> Ian
>
> rtstofer wrote:
> > --- In o...@yahoogroups.com, "Mike Martin" wrote:
> >
> >> Would anyone be kind enough to tell me where I'm going wrong
here
> >> please? I'm trying to write OO code to link a potentiometer to a
> >> servo to make it change its position. I can do it with
procedural
> >> code OK but don't know what object to use in order to make it
work
> >> with OO. Info about linking is a little thin - I need a link to
a
> >> really good explaination to read about objects, pointers and
flags if
> >> any has one?
> >> TIA
> >> Mike M.
> >>
> >> 'Positions a servo using the .position of an
> >> 'oKnob Object (trim pot)
> >> Dim Srv As New oServo 'Make a servo object.
> >> Dim Pot As New oKnob 'Make a knob object
> >> Dim Wire As New oWire
> >>
> >> Sub main()
> >> ooPIC.Node = 1
> >> Call Setup
> >> End Sub
> >>
> >> Sub Setup() 'Setup servo properties
> >> Srv.IOLine = 31 'set the servo to use I/O Line 31
> >> Srv.Adjust = 28 'set the servos center to 28
> >> Srv.Operate =cvTrue 'turn the Servo on
> >> Pot.IOLine = 1 'IOLine 1, pin 7
> >> Pot.Operate = cvTrue 'turn on IOLine 1
> >> Wire.Input.Link(Pot.Value)
> >> Wire.Output.Link(Srv.Position)
> >> End Sub
> >>
> >>
> >
> > I know I have made this work before but I'm not on the Windows
box at
> > the moment.
> >
> > We know the oKnob will output 0..255 but oKnobX will output -
128..127.
> > We also know that oServoX operates with signed values of -64..63
but
> > will accept -128..127.
> >
> > So, why not try oKnobX and oServoX?
> >
> > Richard
> >
> >
> >
> > ------------------------------------
> >
> >
>
> [Non-text portions of this message have been removed]
>
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )Re: Help with OO code - rtstofer - Jul 16 11:09:51 2008
An oWire is a 1 bit bus. So use oBus to transfer 8 bit things like:
Dim Knob As New oKnobX
Dim Servo As New oServoX
Dim Bus As New oBus
Sub main()
Knob.IOLine = 1
Knob.Operate = cvTrue
Servo.IOLine = 31
Servo.Operate = cvTrue
Bus.Input.Link(Knob)
Bus.Output.Link(Servo)
Bus.Operate = cvTrue
End Sub
This works with V6 and a B.2.2+ chip. I am watchin the output with a
scope. The output changes from 0.6 mS to 2.3 mS (more or less).
Richard
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )
Re: Help with OO code - Mike Martin - Jul 16 22:43:45 2008
That works! Thanks Richard. I think I understand it a little better
now. I hadn't taken the data width into consideration (if that's the
correct term?)It's a lot more jittery than it is with procedural code
for some reason. With the OO it hunts a lot too but I think there's a
solution to that that I read about earlier. Many thanks.
Mike M.
--- In o...@yahoogroups.com, "rtstofer"
wrote:
>
> An oWire is a 1 bit bus. So use oBus to transfer 8 bit things like:
>
> Dim Knob As New oKnobX
> Dim Servo As New oServoX
> Dim Bus As New oBus
>
> Sub main()
>
> Knob.IOLine = 1
> Knob.Operate = cvTrue
>
> Servo.IOLine = 31
> Servo.Operate = cvTrue
>
> Bus.Input.Link(Knob)
> Bus.Output.Link(Servo)
> Bus.Operate = cvTrue
>
> End Sub
>
> This works with V6 and a B.2.2+ chip. I am watchin the output with
a
> scope. The output changes from 0.6 mS to 2.3 mS (more or less).
>
> Richard
>
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )Re: Help with OO code - rtstofer - Jul 16 23:59:46 2008
--- In o...@yahoogroups.com, "Mike Martin"
wrote:
>
> That works! Thanks Richard. I think I understand it a little better
> now. I hadn't taken the data width into consideration (if that's the
> correct term?)It's a lot more jittery than it is with procedural code
> for some reason. With the OO it hunts a lot too but I think there's a
> solution to that that I read about earlier. Many thanks.
> Mike M.
Try hanging a 1 ufd capacitor between the A/D input and ground. On
the scope I didn't see any jitter. It looked pretty solid.
Richard
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )Re: Re: Help with OO code - Andrew Porrett - Jul 17 4:00:38 2008
At 10:43 PM 7/16/2008, Mike Martin wrote:
>It's a lot more jittery than it is with procedural code
>for some reason.
Because it's doing more frequent updates?
> With the OO it hunts a lot too but I think there's a
>solution to that that I read about earlier. Many thanks.
As has been suggested, you need a small noise filtering cap connected
directly between the A/D pin and ground. Even a small 0.1 uF cap
should do the trick.
...Andy
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )
Re: Help with OO code - Mike Martin - Jul 17 11:28:49 2008
Thanks Andy =96 what's the difference? Between procedural and OO code, I=20
mean? Is it simply the native speed of OO in the OOPIc? (ie not having=20
to be interpreted?)
--- In o...@yahoogroups.com, Andrew Porrett
wrote:
>
> At 10:43 PM 7/16/2008, Mike Martin wrote:
> >It's a lot more jittery than it is with procedural code
> >for some reason.
>=20
> Because it's doing more frequent updates?
>=20
>=20
> > With the OO it hunts a lot too but I think there's a
> >solution to that that I read about earlier. Many thanks.
>=20
> As has been suggested, you need a small noise filtering cap connected=20
> directly between the A/D pin and ground. Even a small 0.1 uF cap=20
> should do the trick.
>=20
>=20
> ...Andy
>
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )Re: Help with OO code - Mike Martin - Jul 17 11:35:52 2008
OK but just on that - does it matter what the value is? ie does a
larger/smaller/type of capicitor's discharge rate ( say, if I don't
have the right one) matter too much? I've read so much where the advice
seems really abtirary! And does the type matter eg electrolytic etc..
Mike M.
--- In o...@yahoogroups.com, "rtstofer"
wrote:
>
> --- In o...@yahoogroups.com, "Mike Martin" wrote:
> >
> > That works! Thanks Richard. I think I understand it a little better
> > now. I hadn't taken the data width into consideration (if that's
the
> > correct term?)It's a lot more jittery than it is with procedural
code
> > for some reason. With the OO it hunts a lot too but I think there's
a
> > solution to that that I read about earlier. Many thanks.
> > Mike M.
>
> Try hanging a 1 ufd capacitor between the A/D input and ground. On
> the scope I didn't see any jitter. It looked pretty solid.
>
> Richard
>
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )Re: Re: Help with OO code - Brian Lloyd - Jul 17 13:39:49 2008
On Jul 17, 2008, at 8:35 AM, Mike Martin wrote:
> OK but just on that - does it matter what the value is? ie does a
> larger/smaller/type of capicitor's discharge rate ( say, if I don't
> have the right one) matter too much? I've read so much where the
> advice
> seems really abtirary! And does the type matter eg electrolytic etc..
The bigger the cap, the slower the response to changes will be.
--
73 de Brian, WB6RQN
Brian Lloyd - brian HYPHEN wb6rqn AT lloyd DOT com
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )
Re: Help with OO code - rtstofer - Jul 17 13:50:06 2008
--- In o...@yahoogroups.com, "Mike Martin"
wrote:
>
> Thanks Andy =96 what's the difference? Between procedural and OO code, I=
=20
> mean? Is it simply the native speed of OO in the OOPIc? (ie not having=20
> to be interpreted?)
>=20
>
There is an inner loop of code that evaluates all peripherals, virtual
circuits and things like that - the interpreter. THEN the interpreter
runs some portion of a line of code. Then back to the inner
evaluation loop.
Virtual circuits will be a lot faster than lines of script (code).=20
You MIGHT get 300 lines of code per minute. Very, very slow.
That's why you want to do everything possible to use virtual circuits.
Richard
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )Re: Re: Help with OO code - Andrew Porrett - Jul 18 7:21:56 2008
At 11:28 AM 7/17/2008, Mike Martin wrote:
>Thanks Andy =AD what's the difference? Between procedural and OO code, I
>mean? Is it simply the native speed of OO in the OOPIc? (ie not having
>to be interpreted?)
For every byte of script code that gets loaded=20
from the EEPROM, the object list in RAM gets a=20
complete processing pass. So one pass through a=20
while loop to do one update could've had 50 or=20
100 parallel passes through the object list.
>OK but just on that - does it matter what the value is? ie does a
>larger/smaller/type of capicitor's discharge rate ( say, if I don't
>have the right one) matter too much? I've read so much where the advice
>seems really abtirary! And does the type matter eg electrolytic etc..
For what you're doing (a manually turned=20
potentiometer, right?), it really doesn't matter=20
much. You'd just be messing with the time=20
constant of the circuit. With a really huge cap=20
(like 10,000 uF), you could turn the pot and=20
watch while the A/D reading slowly caught up. In=20
fact that's what you're doing by adding a small=20
cap - as noise tries to make the A/D reading jump=20
around rapidly, the cap slows down the changes to=20
the point where they have no effect - they just=20
end up cancelling themselves out.
You don't need an electrolytic, nor do you really=20
want one. They aren't designed to filter out the=20
high frequency noise that you're dealing=20
with. Just use whatever non-electrolytic cap=20
you've got handy. Anything in the 0.1 uF or larger range will be fine.
...Andy
------------------------------------

(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )