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.

Wednesday, September 19, 2007

Re: [oopic] oCountdown vs oopic.delay

See below:

carson hoyt wrote:
> Let me see if I understand what you're saying,
>
> "The new oButton objects will allow you to debounce the buttons as well which will make everything work better. Remember that an event will fire when the
> Operate line moves from '0' to '1', it won't fire again until it moves
> back to '0'."
> If I use the obutton object instead of a oDio1, every time I hit the button the oEvent will restart from the begining of the event code? This would actually be very good if this was the case.
>
> Second debounce will in effect return the button to 0 after it has been pressed?

Debounce will make sure the transition takes place. With a regular
"on/off" button this means that the press will register as it is
debounced, you won't return to the default case until your finger
releases the button. oButton will debounce the transition, that is both
the "down" and the "up".

> "I'm not a fan of using ooPIC.delay in anything."
>
> Is this because the oopic will not be able to monitor the other buttons while it is delaying? I actually only need one event to funtion at a time, so that aspect isn't really a problem, not being able to sense incoming event triggers is though. I would experiment with this but I recently burnt out my oopic chip with a improperly designed circuit (forgot the diodes, ha,ha) and am currently waiting for a new chip.

Yes. The ooPIC essentially "freezes" while the .delay is in effect.

> "I would have a function that is periodically called that checks against a timer
> so that processing can go on while something is awaiting a timeout. One
> way to do that is to create a VC (virtual circuit) that is triggered by
> the button press such that it will start a timer that will call an event
> to shut a switch off when it times out. oCountdown is a good candidate
> for that."
>
> Hmmm after looking at the object page for oCountdown I'm not sure that this is what I need. The reason I was using oopic delay was that I needed a way to say wait x amount of time (where x could be any amount of time) before the next step in the oEvent. I feel like I am probably using the wrong words to say something very simple.
> The purpose of this program is to trigger beable to trigger an oEvent and have it function as a piece of procedural programing code within a larger object oriented event-based programing code. Maybe you could give me an example that would have the same effect?

Look again. oCountdown will start at the value you have it set to and
at every clock transition it will decrement until zero, then a flag will
be set that can trigger another event. The countdown rate can be set by
the frequency of the trigger clock you use. oHz1 and oHz60 are simple
to use clocks, oClock can provide another one. There is a lot of
flexibility here. The best part is that this VC can run in the
background without blocking other button presses or anything else that
is currently running. You have two buttons? No problem, define another
VC to handle the other button.

> Thanks for the help I've certainly learned a lot in a short time.

Sure! Have fun,
DLC

> Carson
>
>
>
>
>
>
> ---------------------------------
> Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
>
> [Non-text portions of this message have been removed]
>
>
>
>
> Yahoo! Groups Links
>
>
>

--
------------------------------------------------------
Dennis Clark ooPIC Tech Support
www.oopic.com
------------------------------------------------------



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] oCountdown vs oopic.delay

Let me see if I understand what you're saying,

"The new oButton objects will allow you to debounce the buttons as well which will make everything work better. Remember that an event will fire when the
Operate line moves from '0' to '1', it won't fire again until it moves
back to '0'."
If I use the obutton object instead of a oDio1, every time I hit the button the oEvent will restart from the begining of the event code? This would actually be very good if this was the case.

Second debounce will in effect return the button to 0 after it has been pressed?

"I'm not a fan of using ooPIC.delay in anything."

Is this because the oopic will not be able to monitor the other buttons while it is delaying? I actually only need one event to funtion at a time, so that aspect isn't really a problem, not being able to sense incoming event triggers is though. I would experiment with this but I recently burnt out my oopic chip with a improperly designed circuit (forgot the diodes, ha,ha) and am currently waiting for a new chip.

"I would have a function that is periodically called that checks against a timer
so that processing can go on while something is awaiting a timeout. One
way to do that is to create a VC (virtual circuit) that is triggered by
the button press such that it will start a timer that will call an event
to shut a switch off when it times out. oCountdown is a good candidate
for that."

Hmmm after looking at the object page for oCountdown I'm not sure that this is what I need. The reason I was using oopic delay was that I needed a way to say wait x amount of time (where x could be any amount of time) before the next step in the oEvent. I feel like I am probably using the wrong words to say something very simple.
The purpose of this program is to trigger beable to trigger an oEvent and have it function as a piece of procedural programing code within a larger object oriented event-based programing code. Maybe you could give me an example that would have the same effect?

Thanks for the help I've certainly learned a lot in a short time.

Carson


---------------------------------
Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.

[Non-text portions of this message have been removed]


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/

Tuesday, September 18, 2007

Re: [oopic] Re: Should this code work?

Your idea is a workable one with that design in mind. The new oButton
objects will allow you to debounce the buttons as well which will make
everything work better. Remember that an event will fire when the
Operate line moves from '0' to '1', it won't fire again until it moves
back to '0'. I'm not a fan of using ooPIC.delay in anything. I would
have a function that is periodically called that checks against a timer
so that processing can go on while something is awaiting a timeout. One
way to do that is to create a VC (virtual circuit) that is triggered by
the button press such that it will start a timer that will call an event
to shut a switch off when it times out. oCountdown is a good candidate
for that.

DLC

carson hoyt wrote:
> Well I decided on events rather than directly linking the buttons because I want the dio states to be able to change over time, which isn't shown in this version of the code.
> The actual events would look more like
>
> switch1.state = cvOff (Concerning these first two lines: is there a way to set
> switch2.state = cvOn up some sort of protocol where for instance it was a
> oopic.delay = 25 given that if switch1 was on then switches 2, 3, 4
> switch2.state = cvOff would be off?)
> switch1.state = cvOn
> oopic.delay = 20
> and on and on for a little while
>
> This program is eventually going to be incorporated into a larger program where the events are controling servos and other objects as well.
> In effect what I'm trying to do is set up each event as a short control program which is triggered by a single external button.
> Am I going about this the wrong way, is there another way?
>
> On a related subject if such programs were written how long could they be before the oopic would run out of disk space?
>
> Thanks
>
> Carson
>
>
>
>
>
>
>
>
> bobhedges9 <bhmtr@mindspring.com> wrote: looks like oflipflop would be easier than the events.
>
> --- In oopic@yahoogroups.com, carson hoyt <carr6565@...> wrote:
> >
> > I recently wrote this code to toggle some solid state analog
> switches, but am unsure if the code is bad or if I am screwing
> something else up all together. I have a feeling I got some of the
> hardware wrong, anyone have any suggestions.
> > Oh secondarily, is there some way to sync output signals or does
> that happen automatically. Thanks for the help.
> >
> >
> > Dim switch1 As New oDIO1
> > Dim switch2 As New oDIO1
> > Dim switch3 As New oDIO1
> > Dim switch4 As New oDIO1
> >
> > Dim button1 As New oDIO1
> > Dim button2 As New oDIO1
> >
> > Dim wire1 As New oWire
> > Dim wire2 As New oWire
> >
> > Dim routerstate1 As New oEvent
> > Dim routerstate2 As New oEvent
> >
> > Sub Main()
> >
> > ooPIC.Delay = 250
> >
> > switch1.IOLine = 1
> > switch1.Direction = cvOutput
> > switch1.State = cvOn
> >
> > switch2.IOLine = 2
> > switch2.Direction = cvOutput
> > switch2.State = cvOff
> >
> > switch3.IOLine = 3
> > switch3.Direction = cvOutput
> > switch3.State = cvOff
> >
> > switch4.IOLine = 4
> > switch4.Direction = cvOutput
> > switch4.State = cvOff
> >
> > button1.IOLine = 6
> > button1.Direction = cvInput
> >
> > button2.IOLine = 7
> > button2.Direction = cvInput
> >
> >
> > wire1.Input.Link(button1)
> > wire1.Output1.Link(routerstate1.Operate)
> > wire1.InvertIn = cvTrue
> > wire1.Operate = cvTrue
> >
> > wire2.Input.Link(button2)
> > wire2.Output1.Link(routerstate2.Operate)
> > wire2.InvertIn = cvTrue
> > wire2.Operate = cvTrue
> >
> > End Sub
> >
> > Sub routerstate1_Code()
> > switch1.State = cvOn
> > End Sub
> >
> > Sub routerstate2_Code()
> > switch1.State = cvOff
> >
> >
> > End Sub
> >
> >
> >
> > ---------------------------------
> > Don't let your dream ride pass you by. Make it a reality with
> Yahoo! Autos.
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>
>
>
>
> ---------------------------------
> Be a better Heartthrob. Get better relationship answers from someone who knows.
> Yahoo! Answers - Check it out.
>
> [Non-text portions of this message have been removed]
>
>
>
>
> Yahoo! Groups Links
>
>
>

--
------------------------------------------------------
Dennis Clark ooPIC Tech Support
www.oopic.com
------------------------------------------------------



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: Roboteq motor controller.

--- In oopic@yahoogroups.com, "topservice77"
<alessandro.cofanelli@...> wrote:
>
> I've downloaded and read the whole manual.
> My troubles are?
>
> Can the 4 com ports be all used at the same moment?
> Is the micro fast enought to calculate 4 different PIDs (for 4
> motors) with a max delay of 10 milliseconds?
>
> What my application have to do is:
>
> read the analog value of input 1
> Calculate the pid
> Send the correcting value by com1
>
> read the analog value of input2
> Calculate the pid
> Send the correcting value by com1
>
> read the analog value of input3
> Calculate the pid
> Send the correcting value by com2
>
> read the analog value of input4
> Calculate the pid
> Send the correcting value by com2
>
> All the 4 tasks have to be completed in a total time interval of 10
> Milliseconds.
>

So, you only need 2 com ports? If so, either the ATmega128 or LPC2148
can do the job - easily. But, you have to write the code in C. There
are ATmega devices with 4 com ports but development boards may be hard
to come by.

If you need floating point, on either processor, things will slow down
(relative to integer math). If that is the case, start with the
LPC2148. It is blazing fast.

OTOH, there is a balancing 'bot project around that uses FreeRTOS (a
full Real Time Operating System) with kalman filtering and analog
inputs from an accelerometer and gyro that runs a ton of floating
point (including 2 PID loops) at a 5 mS tick rate to ultimately drive
a couple of PWM outputs to DC motors. This on an ATmega128. I have
never checked to see how much idle time is available but the menu task
seems quite responsive and it runs at a lower priority than the
balancing task.

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/

[oopic] Re: Roboteq motor controller.

--- In oopic@yahoogroups.com, "topservice77"
<alessandro.cofanelli@...> wrote:
>
> I've downloaded and read the whole manual.
> My troubles are?
>
> Can the 4 com ports be all used at the same moment?
> Is the micro fast enought to calculate 4 different PIDs (for 4
> motors) with a max delay of 10 milliseconds?
>
> What my application have to do is:
>
> read the analog value of input 1
> Calculate the pid
> Send the correcting value by com1
>
> read the analog value of input2
> Calculate the pid
> Send the correcting value by com1
>
> read the analog value of input3
> Calculate the pid
> Send the correcting value by com2
>
> read the analog value of input4
> Calculate the pid
> Send the correcting value by com2
>
> All the 4 tasks have to be completed in a total time interval of 10
> Milliseconds.


For your first question: yes and no. The serial ports are hardware
UARTs and the OS handles serial port byte receive and transmit out of
the buffers at hardware native speed. So you could dump data into each
output buffer -- one buffer at a time -- and have a bunch of data
queued up in the buffers which will be transmitted in the background.
There's no command to toss data out on all the buffers simultaneously
and have them transmit in sync. Data reception is similar, though it
might get tough to handle a lot of interrupts rather than poll the
buffers looking for input. Anyway, based on your pseudocode you were
looking for fire-and-forget serial ports, which is close enough to the
reality here.

Doing something in 10 milliseconds is another tough one, same as
OOPic. We can do 360 instructions in that timeframe. That means,
assuming no other overhead, you have 90 BASIC instructions for each
PID. The analog reading will take 1 to 2 instructions, but you don't
have much room for doing any software filtering. I don't know how
complex your PID routine is going to be.

So it *may* be possible. It all depends on how much calculation you
actually need to do. Each part of the calculation (addition, copying a
variable, etc) will take an instruction, but there is no penalty for
floating point calculations.

If you're not sure, you could take advantage of the 30 day money back
guarantee and just try it.

However, it might be worth it to learn a little C or assembly and
write native code for a microcontroller, as several have already
mentioned. You'll definitely have enough elbow room for calculations
if you go that route. The downside is having to roll your own routines
for just about everything.


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: Roboteq motor controller.

> You only have integer math (unless you tack on an external floating
> point unit) and MAYBE you can execute 400 lines of code per second -
> about 2.5 mS per line. Some lines take longer than others. But even
> if you assumed 1000 lines of code per second, it would mean 1 mS per
line.

My questions was about the cubloc microprocessor.
I'm sure i can't reach the needed speed with oopic, i was asking if
with the cubloc hardware i can reach it.


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: Roboteq motor controller.

--- In oopic@yahoogroups.com, "topservice77"
<alessandro.cofanelli@...> wrote:
>
> I've downloaded and read the whole manual.
> My troubles are?
>
> Can the 4 com ports be all used at the same moment?
> Is the micro fast enought to calculate 4 different PIDs (for 4
> motors) with a max delay of 10 milliseconds?
>
> What my application have to do is:
>
> read the analog value of input 1
> Calculate the pid
> Send the correcting value by com1
>
> read the analog value of input2
> Calculate the pid
> Send the correcting value by com1
>
> read the analog value of input3
> Calculate the pid
> Send the correcting value by com2
>
> read the analog value of input4
> Calculate the pid
> Send the correcting value by com2
>
> All the 4 tasks have to be completed in a total time interval of 10
> Milliseconds.

Well, all you have to do is add up the total number of characters to
be transmitted to get the answer. At 9600 baud, it takes about 1 mS
to transmit 1 char. But that would assume that the A/D input and
calculation took zero time - they surely don't. For the bit-banged
serial port, there is no buffer. So, no overlapped IO.

You only have integer math (unless you tack on an external floating
point unit) and MAYBE you can execute 400 lines of code per second -
about 2.5 mS per line. Some lines take longer than others. But even
if you assumed 1000 lines of code per second, it would mean 1 mS per line.

You have a budget of 2.5 mS per channel so I certainly wouldn't think
it would work.

Extensive calculation and bit-banged serial IO is not a good fit for
the OOPic.

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/