2

Author Topic: Webbot lib and PC communications  (Read 636 times)

0 Members and 1 Guest are viewing this topic.

Offline mstachoTopic starter

  • Supreme Robot
  • *****
  • Posts: 364
  • Helpful? 10
Webbot lib and PC communications
« on: March 28, 2011, 08:23:38 AM »
Here is the idea behind what I'm trying to do (on an Axon, if it matters):

Have the PC monitor the UART1 (which in my case is acting like a com port).  The PC will send an encoder position to a DC motor that is being controlled by the Axon.  Once the Axon moves to that position, it sends data to the PC and requests more.  So the flow of the program should be:

1) SET AXON MODE: Ready to accept data
2) LOOP until PC sends data
3) RECEIVE PC data
4) EXECUTE PC instructions while querying the UART in case the PC sends an interrupt command
5) WHEN FINISHED, return to 1

Now, with the old Axon code, this works perfectly fine, since I have control over my program loops.  With Webbot lib, I don't seem to have this control -- the scheduler just keeps calling my appControl function whenever it's done.  This leaves me in something of a problem:

I wonder if it's possible to set a global variable that persists outside of a call to appControl, so that when we go back into appControl the Axon can still know which of its execution modes it's supposed to be in.  The Axon also has to store the instructions that the PC sent it during the last time through the loop, so that if the motion takes longer than one time through the old setpoints are not lost.

I hate to declare everything as a global variable (I'm not even sure I can in the Axon?) is there an easier way to gain control over my program loops?

MIKE
Current project: tactile sensing systems for multifingered robot hands

Offline mstachoTopic starter

  • Supreme Robot
  • *****
  • Posts: 364
  • Helpful? 10
Re: Webbot lib and PC communications
« Reply #1 on: March 28, 2011, 11:45:10 AM »
Turns out the answer is really simple.  Webbot lib really DOES just do it all for you :-P  For the curious, the pseudocode works like this now:

AXON:

1) Check if the uartReceiveBuffer is empty. If it is, then the Axon continues to execute any instruction it already has.  At initialization, this means that all the PID controllers should just output zero.

2) If the buffer is not empty, read it and implement the instructions (in my case, these instructions are encoder values to go to).  Thus, when implementing the instructions, set the PID set points to what is in the message.  **because the webbot library maintains the PID controller objects outside of your main program, this solved my problem of not needing to use global variables**

PC:

Send whatever instructions are generated whenever it is necessary.  The Axon will handle everything when it receives them.

If anyone has the same problem, I can upload my code.

MIKE
Current project: tactile sensing systems for multifingered robot hands

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,659
  • Helpful? 169
    • Society of Robots
Re: Webbot lib and PC communications
« Reply #2 on: April 04, 2011, 06:57:26 AM »
Yeap, thats basically what I do with my ERP when it's wirelessly/voice controlled.

Quote
I hate to declare everything as a global variable (I'm not even sure I can in the Axon?)
Yeap it's possible, but always avoid globals when you can.

 


Get Your Ad Here

data_list