
nogare321
USA
Asked
— Edited
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!
Its the EZ-SDK you would use, not ARC. ARC is a standalone graphical control software. You can watch a video about the difference between EZ-SDK and ARC by pressing the DOWNLOADS button on the top of this webpage
Thanks!
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!
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 '--')
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?
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.
This might help: http://www.mathworks.com/help/matlab/matlab_external/exploring-your-object.html
I'll need to work out how to load the board dll files into MatLab.
Thanks for your advice.
Is there a reason you are not using Visual Studio? Or even ARC?
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!
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!