Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: casual tinker on December 11, 2010, 01:01:07 AM

Title: some questions from a beginner
Post by: casual tinker on December 11, 2010, 01:01:07 AM
I just signed up with SoR after reading some of the tutorials, and I have a question or two to start out. I'm gonna try to keep it short and to the point:
Of course I want an autonomous robot, but I would love RC capability as well. Would it be possible to have both, and have a switch that controls whether the microcontroller or the receiver is connected to the servos? So I would simply flip the switch to go from remote control to autonomous.
I know I'm supposed to keep it simple, and I promise I'll try to in every other way, this is the only fancy-ness I want to get up to. Otherwise I plan on following the $50 Robot, Remote Control Robotics, etc tutorials. I am on a tight but not impossible budget, as I am a high schooler with some income but also college to consider.
I think that's all I'll ask for now so I know if my idea is even possible before I launch anything. Thanks for the help!
Title: Re: some questions from a beginner
Post by: aruna1 on December 11, 2010, 01:43:31 AM
hi its possible.
from what i understand from your question you can do with your code like following

main()
{
while(1)
{
  while(switch_on)
  {
    do your remote control coding here
  }
  while(switch_off)
  {
    do your autonomous coding here
  }
}
}

so when you turn on the switch it program will infinitely execute your remote control operation until switch is off.once its off it will act as a autonomous robot
Title: Re: some questions from a beginner
Post by: rbtying on December 11, 2010, 02:38:49 AM
It's simpler than that:

Code: [Select]

int main() {

while (1)
   if (autonomous) {
     //do autonomous code
   } else {
     // do manual code (RC)
   }
}
Title: Re: some questions from a beginner
Post by: casual tinker on December 11, 2010, 02:28:58 PM
That sounds simple enough... but since this is my first robot I don't really know. I'll probably ask for clarification later.

As far as the physical switch, is it as simple as building the $50 robot and the remote control robotics and then wiring the servos and batteries to both? And then putting a switch... in between the servos and microcontroller or where? I'm sorry I bet I'm not being clear, but I don't completely know what I'm doing yet (hehe....) bear with me
Title: Re: some questions from a beginner
Post by: rbtying on December 11, 2010, 04:13:53 PM
It would work, but not really autonomously.  A better way would be to connect the RC receiver to GPIO on the controller (just the signal wire), read the pulse width, and use that to determine how fast to drive the motors.  An extra channel could be used to decide autonomous/remote. 
Title: Re: some questions from a beginner
Post by: casual tinker on December 11, 2010, 05:32:40 PM
Ooohhh so the microcontroller can do the receiver's job if I attatch the signal wire? I didn't even think of that (shows what a beginner I am haha). So I should assemble the $50 robot and then add the RC function afterwards, I think.
Title: Re: some questions from a beginner
Post by: rbtying on December 13, 2010, 08:54:20 AM
Ooohhh so the microcontroller can do the receiver's job if I attatch the signal wire? I didn't even think of that (shows what a beginner I am haha).

The microcontroller acts as a passthrough on RC mode, and as an autonomous controller when in autonomous mode.  Basically, the uC receives servo commands from the receiver, which are read and then rewritten to the servos, in RC mode; while in autonomous mode the radio signals are ignored and sensors are used with command logic to determine the servo drive values.

So I should assemble the $50 robot and then add the RC function afterwards, I think.

Yes.  Don't make things too complex until you've gotten started - RC functionality is probably not something you want to fiddle around with until your board is near-perfect:  the expensive DSM2 receivers, at least, cost easily $60 to $100, and losing that to a accidental short would really suck.