Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.

Get Started
Asked — Edited

Matlab Control Of The Board

Hi,

I'm currently working on a project where I need to be able to control the EZ-board through Matlab. I've managed to connect to the board over Bluetooth using Matlab, but I'm now stuck on the syntax and commands I need to use.

My questions are:
1- Do you have a list of the commands that are used in the ez-builder?
2- What terminator charracter does ARC use at the end of the commands it sends to the board?

Thanks for any help!

AI Support Bot
Related Content
Synthiam
#2  
Oh, I hadn't realized the SDK manual was online only. I could only find the down loadable one for the ARC.

Thanks!
#3  
OK, I've had a read of the SDK manual and come to the realization that my programming skills are not good enough for me to understand my problem.

I'll try to explain the problem I'm having in more detail.

Using MatLab I can connect to the board (the Bluetooth light stops flashing). However, when I send commands over Bluetooth nothing happens. My commands are formatted as shown below, with ezb being the Matlab reference for the board.

fprintf(ezb,'Servo.SetServoPosition(Servo.ServoPortEnum.D0,60)')

The fprintf command is a Matlab function to print to a file (or in this case the board I think).

I know something is happening as the main data LED stops flashing while this command is set, but the servo doesn't move. After a few minutes the data LED starts flashing again.

I know fprintf works over Bluetooth as I can communicate with and control a distance laser sensor using the same format. Thus, I know I've missed something in the connecting stage or command syntax stage.

I'd really appreciate your thoughts on where I've gone wrong!
Thanks!
Belgium
#4  
You might want to see the Python scripts I have posted (search for 'Python' on these boards).
Given the similarity of Python and Matlab, it might give you some more pointers.
You need to send a command to the board regularly, otherwise it disconnects.
Here is my Wait() function in Python, which gets used whenever the EZ-B is doing nothing:

def wait(my_ezb,seconds):
--from time import sleep
--seconds = int(seconds)
--for i in xrange(seconds):
----for j in xrange(10):
------#regularly send a command to the board to keep it connected
------my_ezb.Uart.SendSerial(my_ezb.Digital.DigitalPortEnum.D1, my_ezb.Uart.BAUD_RATE_ENUM.Baud_57600, "1")
------sleep(0.1)

(indents shown as '--')
#5  
Thanks, I'll look into this.
I didn't realize that the board needed to be in constant communication. Just curious, but why does the Bluetooth light stay on constantly if the board disconnects?
#6  
This next question will probably show my ignorance, but what is the EZ_Builder actually sending to the board over bluetooth when servo D0 is told to move to position 70. i.e: Servo(D0,70)

I'm just trying to work out why my commands are being received (as the LED stops flashing), but nothing happens.

@dalex: Thanks for your input, but I don't seem to be able to use your tip correctly. I've tried making a script that fires commands at the board constantly, but I get the same results. I think my problem is I don't know how to speak to the board in a way it understands.
#8  
Ok, I guess this will take longer then I was planning.
I'll need to work out how to load the board dll files into MatLab.
Thanks for your advice.
PRO
Synthiam
#9  
It will take a bit longer, to learn programming in MatLab - but once you get it, it'll be a breeze:)

Is there a reason you are not using Visual Studio? Or even ARC?
#10  
I already know a little basic programming in MatLab, just not enough to communicate properly with the EZ-Board.

There are three main reasons I'm using MatLab over ARC and Visual Studio.
1) I'm more familiar with MatLab.
2) I need to communicate with two devices over bluetooth. The EZ-Board and a distance sensor.
3) I need to create a custom GUI to control both devices.

Would you be able to tell me what the EZ-Board sees when ARC sends the command: Servo(D0,60) through the script console? Does ARC interpret this command to binary or assembly?

Thanks!
Belgium
#11  
... or Python?
#12  
Just in case anyone else ever has this problem, I've managed to get MatLab working! (angelic hallelujah chorus in background). It was relatively simple, like all good fixes. It just took me hours to workout MatLab's confusing methods.

The code to connect to the board is as follows:

asm = NET.addAssembly('pathName\EZ_B.dll')
board = EZ_B.EZB;
board.Connect('COM6');

To control the servos the code is:

board.Servo.SetServoPosition(EZ_B.ServoPortEnum.('D0'), 20,2)

This should move servo D0 to position 20 at speed 2.

MatLab seemed to do something funny with the Enums, compared to Visual Studio. The Enums were listed (by using the command asm.Enums) as 'EZ_B.Servo+ServoPortEnum', yet in order to use the Enum it had to be writen as I did in the above command. Very strange.

Hope this helps someone in the future!