I'm still trying to get this serial communication between MATLAB and the Diecimila board working properly. I have some communication happening, but it's not predictable. All I'm trying to do at the moment is receive a 5 from MATLAB and send it back. My Arduino code just does this:
As you can see, there is something being sent to the Arduino. I had it coded so that the onboard LED turned on if Serial.available() became not 0, and it worked. There is something being sent both ways, it's just that I can't figure out how to send a specific value. Sending a 4 always receives a 112 while a 5 returns a 65 every time. I can't figure out if I'm sending it wrong from the Arduino - i.e. Serial.print(input,DEC/HEX/BYTE...) - or from MATLAB - i.e. encoding it as uint8. Can someone help me? I have the RS232 connected to ground, tx to pin 0, and rx to pin 1 on the Arduino board and the other end into COM1 on the computer.
Wow... Grumpy_Mike, thanks for that. I didn't have a converter in the circuit. The stupid thing is that I knew that I needed one, but apparently, that's not enough for me. Someone told me this last week, I saw the circuit for the MAX3323 chip on arduino.cc, and I even took a class last semester on serial communication protocols and it didn't stay with me when I was actually working on the circuit. I guess the stress is just getting to me. I'll try that right away and let you know.
We are simply using MATLAB to control a linear actuator via stepper motor and Arduino. That part isn't too exciting, but its purpose is pretty cool. It's for use as an extension to a 3-d positioning system which is meant to characterize an electro-magnetic beam, which is itself used to irradiate cancer from cancer patients. This is part of a final year Engineering design project.
On a technical help note I spoke with someone at my university who works with serial and micros. He said that while the voltage requirements are different between USB and RS232, he has never actually experienced a problem getting the two to communicate without any voltage regulators or whatever. He suggested it was a problem with baud, parity, or stop bits. Does anyone know what the Arduino uses for serial communication (i.e. # of data bits, # of stop bits, if it uses parity...)? I couldn't find anything on the website.
Just to put this on the forum, I have fixed the problem. The problem was two-fold: I was not accounting for the voltage differences between USB and RS232. I got the MAX3323 chip and hooked it up according to the site (http://www.arduino.cc/en/Tutorial/ArduinoSoftwareRS232) but it still didn't work.
I had to change the values for the bit9600delay values as described by the above site. It worked with slightly higher values. I'm not sure exactly why but anyway...
Glad to here you got it working. As to your friend:-
He said that while the voltage requirements are different between USB and RS232, he has never actually experienced a problem getting the two to communicate without any voltage regulators or whatever.
He is either a lire, an idiot or he never experienced a problem because he never tried it.
Actually, I just think it was a miscommunication. He is a tech guy at the university and in days past, when there was no WIFI, all their communication was done over long serial lines. So, he has quite a bit of experience with that. I haven't sat down and gone over exactly what we did to make it work because... well it works so I don't really care I'm too busy for that.
In any case, I'm sure glad I found the resources on this website. Thanks to all the great folks who have helped.
Hi guys,
I'm trying to program a couple of server motors using matlab and working with arduino. I don't know much about electronics etc. or programming, but need to do it for a uni project that I'm working on. I'm working through a usb, so perhaps that's the problem? Do any of you think that I should try the RS232-TTL converter?
Any tips at all would be greatly appreciated.
Thanks!
I'm working through a usb, so perhaps that's the problem? Do any of you think that I should try the RS232-TTL converter?
Not a lot to go on here. The only advantage of using RS232 rather than the USB is that the drivers are normally loaded onto a PC for the built in COM ports. Other than that there are no differences. So if you have drivers installed in the PC and are communicating with the arduino then you should have no difficulty using that over RS232.
Hey,
Thanks for that. Also, do you know if there's any issues with different versions of Matlab and how well they work with Arduino? We're currently having some problems with Matlab working with our Arduino board.
Thanks again.