I would like to quickly setup an asynchronous duplex RS232 (or USB) communication between LabVIEW 2009 and a PIC16F8xx. Before I get stuck in, does anyone know if there are any reference code templates or examples available for either LabVIEW, assembly or c code (using the CCS compiler) to speed up the development?
Can you tell us more about what you plan to do. I have used this approach many times. And I can give you some tip. If you are new to this perhaps a RS 232 link is the best. But this will depend on the data rate
Hi, It's a fairly generic application (which is why I started a new thread!) My PIC is generating a PWM output, I'd like LabVIEW to send commands to modify the pulse shape. My commands are simply one character (a, f or p) to represent the parameter to change, followed by an int. So f100 is change frequency to 100. I've sorted the write functions out using an event structure, but I'd like to now add a serial read so I can echo back from the PIC to help with the assembly code writing. I haven't used event structures much with VISA functions. I'd like an interrupt style read.
I could not run your code, since a VI is missing and I do not have your hardware. But that is OK. You had some labview no-no that I correct in your code. Also be careful with using globals and locals in your code. They may slow down your code. Global and locale variables are not pointers but a copy of the original data. A few global/locale with short strings and some values will not hurt you much. But large arrays and complex clusters will do.
Also have you considered using C and not assembly code. It will make things simpler for you. The last thing is KISS (Keep It Simple Stupid). That is a phrase I learned in my time in the army. What is mean is that then you try to do things in a fancy but overcomplicated way. You will quite often fail. As an example if you send the code f100 to your microcontroller you must decode the 100 value into binary number. So why not send the vales as one or more binary bytes that the microcontroller do understand directly. But beware of the endian format.
Thanks for your help. I meant to keep the range of values within a byte but now realise the padding is unnecessary (attached missing vi.).
At the moment the PIC is just adding one to the first ascii character and returning it. It looks ok on the oscilloscope but the read is still not working.