Optimize cog for my application
micman2
Posts: 18
Hi all, sorry for my English
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
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
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
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
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