loading
 
RoboRealm Propeller MCU Examples / Help Needed
Steve Woodrough from United States  [46 posts]
4 years
Well Iíve gotten this far with my Robo Magellan project:

https://www.youtube.com/watch?v=8eACDNHX7Lw

and now Iíve decided to add some vision.

Does anybody have experience they can share on using the Propeller_Communicator.Spin object and the RoboRealm MCU module?

I just need a nudge in the right direction.

Best Regards,
Steve
Steven Gentner from United States  [1371 posts] 4 years
Steve,

I assume you saw the SPIN code at

http://www.roborealm.com/help/Propeller_Communicator.zip

which will allow you to send values from the MCU to the Propeller. In your case I'd expect it to be something along the lines of the best recommended position of the orange cone. Perhaps pixel location or just left/right signals. It depends on which environment you want to perform more of the calculations (i.e. on the PC or in the Propeller).

You would do this by placing a variable in one of the mailboxes in the RR module which would then transmit that value to the Propeller. You'd then need to decide what you want to do with that value and use it in your existing code.

Or is there another direction you were hoping for help in?

Nice video! Sweet system. Should do quite well!

STeven.
Steve Woodrough from United States  [46 posts] 4 years
STeven,
Thank you for the prompt reply.  As an introduction, I am a ďgear headĒ by nature and have limited experience in programming.  I have applied some fundamentals to get where I am and adapted objects written by others, but it does not come easy.    

Yes, I have seen the SPIN file.  Seen, but I do not understand how to use.  

I was able to follow and apply the other example posted on the forum using the approach

rxVal := rxVal_1 | (rxVal_2<<8) | (rxVal_3<<16) | (rxVal_4<<24)

While I do not fully understand this approach (why are some values in parenthesis?), I was able to send the mouse X and Y data to the Prop using the Serial module and control servos.  

What I want to do is support bi-directional communication.  In some cases I want to send data as you described (COG, Path, etc.) from RR to the Prop.  In other cases I may want to send data from the Prop to RR.  

Looking at the SPIN file on the RR site it was not clear to me exactly what I would need to put in my code to associate data with a  RR mailbox and transmit to RR or in reverse, to accept data from a RR mailbox and equate that to a variable within the Prop.  

What is the SPIN syntax to send data from the Prop to RR?:

Mailbox[1] := <someSPINvariable>    ???

What is the SPIN sysntax to receive data from RR?;

<someSPINvariable> : = Mailbox[2]    ???

Iím committed to resolving this and would be open to posting the completed solution on both the RR and Parallax forum.  

Best Regards,
Steve
Steven Gentner from United States  [1371 posts] 4 years
Steve,

Sounds good. I'll explain a bit more:

The parens in

rxVal := rxVal_1 | (rxVal_2<<8) | (rxVal_3<<16) | (rxVal_4<<24)

is to be explicit in the order of execution. Do you << first or use | first. The parens clarify that. In some cases these are not needed but just to be safe its good to use them since they add to clarity.

The Spin syntax to send data from the Prop to RR is located in the processMailboxes function example at the bottom of that file. Depending on the data type that is used you can use

intValue[1] := some spin variable
mailboxSendFlag[1] := 1

and to use the data it would be

some spin variable = intValue[2]

Note the use of intValue, logicValue, textValue arrays to  hold data based on the type. As SPIN is not a very rich language, its a very primative way of doing this without getting things to be too confusing.

Note also the use of mailboxSendFlag to tell the function that there is data to be delivered. This helps reduce the traffic between prop and pc.

Does that help?

STeven.
Steve Woodrough from United States  [46 posts] 4 years
STeven,
Possibly, let me mess with it and reach back out if / when it does not work.  I'm accustomed to calling items through methods.  This approach is just a bit foreign to me.  Looking ahead, Iím using the 4 port serial object to communicate to GPS, LCD, and PST terminals using only one cog.  Iíll need to eventually adapt your object to use 4Port serial to avoid starting another cog.  

First things first though.  Let me try to make this work in the native environment and expand from there, baby steps.  I will be in touch.

BTW RR is a way cool tool!    

Best Regards,
Steve

Steven Gentner from United States  [1371 posts] 4 years
Steve,

Sounds good. Just to give you another option that you might be more familiar with, you mention the GPS is attached to the prop. If that type of signal is easier to deal with (i.e. ascii text) you can always use the serial module in RR to send strings to the prop instead. Maybe that approach is easier to get going since you have something similar already running.

The serial module is more freeform that allows you to specify whatever you want. So you can always use

[COG_X], [COG_Y]<cr><lf>

in the serial module to send X,Y coordinates. Same with the reply. This is easy to work with but really only for a few values. Otherwise, the MCU Communicator is better.


I.e. go with what you already know.

STeven.
Steve Woodrough from United States  [46 posts] 4 years
STeven,
I was able to us the MCU to pass integer data from the Prop to RR on my flight home last night.  Had to shut down before I could expand my test.  Give me a few days, and I'm sure I'll have a list of questions.
  
Thanks, Steve

p.s. I'm familiar with the approach you described in the previous post, and agree that the MCU is a better way of doing things.    
Steve Woodrough from United States  [46 posts] 4 years
STeven,
SPIN CODE to get data from the Prop to RR works just fine:

     intValue[1] := Prop                                'Set array variable to the value of the local varaible
     mailboxSendFlag[1] := 1                            'Transmit value to Mailbox 1 in RR

What is the syntax to get a string from the Prop to RR?  I tried:

     textValue[2]:=Serial.str(string("String from Prop"))
     mailboxSendFlag[2] := 2                            'Transmit value to Mailbox 2 in RR

but it did not work.  Compiled yes, work no.  
Best Regards
Steve
Steven Gentner from United States  [1371 posts] 4 years
Its something along the lines of

  BYTE myStore[1024]
  myStore[0]='T'
  myStore[1]='e'
  myStore[2]='s'
  myStore[3]='t'
  myStore[4]=0

  textValue[2] := myStore
  mailBoxToSend[2] := 1

note the difference between mailboxSendFlag and mailBoxToSend. One indicates mail is to be delivered whereas the other specifies the type. The type is send from RR when you setup that variable as a text input so you should not need to do anything with that array.

That's the raw requirements ... you may try

textValue[2]:=string("String from Prop")

but I'm not sure what string actually does in terms of bytes. The requirement for this is a single byte string terminated by a zero. Note that you cannot transmit high order ascii characters (above 127).

There also seems to be some duplication in sending the string back to RR. The lines

           serial.tx(buffer[0])
           serial.tx(buffer[1])
           serial.str(tvalue)          
           serial.tx(buffer[2])

should instead not send buffer 0 and 1 again (already did in previous statements) so just delete those 2 lines to be

           serial.str(tvalue)          
           serial.tx(buffer[2])

STeven.
Steve Woodrough from United States  [46 posts] 4 years
STeven,

Iíve spent a bit of time experimenting with the MCU and other RR modules.  Below are a few notes, observations, and possibly a bug to report.  For the time being I will focus on exchanging integer data since that is likely the most useful format.   Copies of the SPIN code, Robo file, and a screen shot are included.    

The experiment so far involves exchanging data between the Prop and RR.  There are 10 variables P0-P9 that are incrementing in the Prop and sent up via the MCU in mailboxes 0-9.    

Bug?:  The 3rd mailbox in the Watch Variable module does not appear to be working correctly.  This value stays 0 most of the time.  Occasionally it will flicker to be in the line with the other data, but then returns to 0.    

In Mailbox 10 and 11, RR sends the value of  Mouse_X and Mouse_Y to the Prop.  The Prop code accepts this data and re-transmits X and Y in mailboxes 12 and 13 respectively.  Mailbox 14 is the sum of the X and Y, as calculated by the Prop.  

Bug?:  In the Display Variable module, the variable names sometimes change when moving the variables from window to window or within a window.

Lastly, the Mouse_X Y data does not seem to update nearly as often to the Prop as often as data is transmitted from the Prop.  The result is that there is a data lag, measured in seconds, between the mouse data displayed by RR and that same data reflected from the Prop.  Note the difference in data for the mouse data in the attached screen shot.  

Basically what I have works, or can be worked around, but I would like resolve the matter regarding Mailbox 3.  

Best Regards,
Steve
Steve Woodrough from United States  [46 posts] 4 years
Files attached.
Steve Woodrough from United States  [46 posts] 4 years
Can't attach SPIN files.

 

program.robo
Steven Gentner from United States  [1371 posts] 4 years
Steve,

Can you zip up your SPIN file and post it here? Zip should be able to get through. We have a couple theories as to why you are seeing those errors but want to replicate before we make any suggestions.

Thanks,
STeven.
Steve Woodrough from United States  [46 posts] 4 years
Code Posted.  Thanks!
Propeller_Communicator_EXPERIMENT - Archive [Date 2013.07.24 Time 08.09].zip
Steven Gentner from United States  [1371 posts] 4 years
Steve,

So the mailbox 3 issue is caused by the existing example code in the Communicator SPIN file. The idea is that you would populate the processMailboxes function with your own code. As you have created a new routine and called it before the actual core of the Comminicator code, the mailbox 3 is getting set to 0 or the input of pin 17.

Can you move your SendData to where the processMailboxes gets called at the MCU End Frame (and remove our routine). That should solve the mailbox 3 issue and free up Servo channel1 and stop pin 16 from toggling (all that is in our example function).

We'll also make these changes and check on the delay issue. This issue we beleive is due to the pause(100) which is getting called very frequently based on where you put DataSend. Once you move that function to MCU_END_FRAME that will help to reduce that delay. Even with that, unless there is a very compelling reason to have that pause I'd remove it entirely as that will still cause the communication to slow.

Thanks,
STeven.
Steve Woodrough from United States  [46 posts] 4 years
STeven,
This is what happens when newbies get messing around in code they do not fully understand.  I see the error of my ways, and the recommended corrections fixed the issues.  
There is still an issue when moving variables in the display windows.  Sometimes the displayed name is changed to some other variable name.  The work around is to remove the variable from the display and reinsert.   An annoyance at best.  Neat product!  
Best Regards
Steve
Steven Gentner from United States  [1371 posts] 4 years
Steve,

No worries, glad we could help resolve those issues.

With regards to the variable changing name, I assume you are using the yellow buttons to move the variable to different locations and then once you do this suddenly the variable changes its name? So something like IMAGE_COUNT could suddenly become IIIGE_COUNT? Or does it replace it entirely with a different valid variable name?

We're trying to replicate the error but not seeing any issues.

Thanks,
STeven.
Steve Woodrough from United States  [46 posts] 4 years
STeven

Using RR version 2.50.44
See attached image.  

In the attached image the variable name P1 2211 is locked and is the result of moving P9 up with the arrow buttons.  Note how other values have incremented along.  Sometimes this happens, other times the name changes to Mouse_X or similar existing variable.  In that case Mouse_X data is NOT displayed, just a static display of the changed name.  Also note in this case that P9 is newly available from the variable selection list.  The system knows that the variable is lost, since it is returned to the availability list.  In other words, I could now re- select P9 and insert it wherever I choose.

On another note: Data refresh rate is about 1 Hz for all data coming from the Prop.  Mouse_X / Y data coming direct from RR updates in real time.  SPIN zip file attached.  I don't see any other pause or wait count that would cause this.  Each time the date refreshes, P0 and all the other variables, are about 8 to 10 increments along, 20 to 30 more if the mouse is moving.  In one frame P0 = 2310, in the next frame P0 = 2318, then 2328 etc.  The Prop is cycling along, but data is not being sent up timely.  

Hope this helps!  

Best Regards
Steve

 

Propeller_Communicator_EXPERIMENT - Archive [Date 2013.07.25 Time 18.48].zip
Steve Woodrough from United States  [46 posts] 4 years
STeven,

I am coming around full circle and suspect that the regular serial driver may be a better approach for my needs.  Iím reasonably comfortable sending data from RR to the prop with the technique you described.  For example I can take the Mouse X and Mouse Y  information and control a servo over either cable or Blue tooth connection.  

Can you provide guidance on how best to flow and associate data from the Prop to RR.  I can transmit data from the Prop and see it in the RR Console window, but Iím having trouble linking that data with a specific variable in RR.  Ultimately what I want to do is transmit my Latitude, Longitude, speed, and heading values from the Prop and display those on the screen.    

Best Regards,
Steve

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index