Shop OBEX P1 Docs P2 Docs Learn Events
Optimize cog for my application — Parallax Forums

Optimize cog for my application

micman2micman2 Posts: 18
edited 2009-05-07 09:17 in Propeller 1
Hi all, sorry for my English blush.gif

I do building the special robot for Disability.

In hardware I have 2 wheels and two motor with encoder and 1 joystick :

I would control the system with propeller controller, I like propeller cool.gif

The function :

- Read 2 encoder
- 2 PWM for motor
- 2 PID for control motor velocity and acceleration & decelleration
- 1 serial (I would apply the "easy bluetooth" see in parallax components)
- 1 SPI slave for future control with another uC
- 1 joystick

My problem is how to optimize the task of cog.

I thought of doing this :

1- cog for read 1 encoder left
1- cog for read 1 encoder right
1- cog generate pwm for motor left
1- cog generate pwm for motor right
1- cog for control velocity (PID) and acceleration&deceleration
1- cog for serial TX/RX
1- cog for SPI slave
1- cog for Main which manages all the system (read joystick send velocity in the PID read SPI, Serial and executes the commands)
=
8 cog!

Is too expensive so? I can optimize some function?

Thanks
Michele

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2009-05-07 09:17
    You sould have a look at the ObExchange. There you already find a PWM·motor driver object that can control serveral motors ( I think it was 32) with only one COG. I'd say that reading the encoders is no problem for one COG as well and maybe it can read the joystick as well.

    The rest depends on the needs. What is the serial interface used for? What is the SPI slave used for? Do you expect to receive/send data on both interfaces on the same time?

    In your current situation there·is only·a minor reason to optimize for COG usage: power consumption
    On the other hand - doing more than only one thing in one COG is a bit more complicated. If you have a look at the FullSerialDuplex object you can see what I mean. So, if you don't figure out how to code reading the joystick and read the encoders, then do it in 2 COGs.

    But it might be that your project goes in a direction where you attach additional devices to it and every free COG will be welcome.


    Post Edited (MagIO2) : 5/7/2009 9:31:55 AM GMT
Sign In or Register to comment.