Jump to content

Microcontroller PWM/ADC/DigPort Code & LabVIEW Testbench


Justin Reina

Recommended Posts

Hey jmt6009,

Here is how to get AVR Studio up and running,

(1) Install WinAVR: http://sourceforge.net/project/showfiles.p...ackage_id=66543

*Download the '-install.exe' file

(2) Install AVR Studio: http://www.atmel.com/forms/software_downlo...dio416Setup.exe

*Fill Out Registration

(3) Install MkII Driver

*Plug In mkII

*Go through Auto-install sequence from Windows

(4) Plug mkII into your devboard's ISP

*Manual: http://www.atmel.com/dyn/resources/prod_do...RISPmkII_UG.pdf

*Don't Proceed until the micrcontroller LED goes from red to green

*If it is red, check your wiring and setup. this part might not be fun :(

(4) Open AVR Studio

*For now don't open a project (*.aps file), so hit cancel at the main dialogue

*Open the Programmer Window (see openProgrammer.jpg)

*Check for device (see checkDevice1.jpg & checkDevice2.jpg)

*Set Correct Clock Fuse Bits (see setCorrectClockFusebits.jpg)

*Uncheck the clock divide fuse (see uncheckClkDivide.jpg)

*Make sure to hit program after making fuse changes

(5) Load the binary file (the *.hex file)

*Try the togglePins.hex first (see program.jpg)

*This is the 'code' that runs on the uC

(6) Hopefully it works :)

*Work through the examples. They should get you up and running.

@all: Here is previous thread: http://forums.lavag.org/Using-the-USB-6008...I-O-t13671.html

Best of Luck,

-Justin

*All the Atmel code and LabVIEW code is in the zip file

Link to comment

Justin,

Thanks so much! I'm back home for the weekend, and I have an interview out in California Monday, but as soon as i get to my lab at school on Tuesday I'll work through all of this. :). Just a quick question, i remembered having a problem connecting the 6 pin programmer to the 10 pin slot on the dev board. Is there simple way to wire this together?

Thanks again! I'll post some videos as soon as I get everything running :)

-Jim

Link to comment

Just found this nifty guy online ($4 for an ISP 6-10 adapter)

http://www.nkcelectronics.com/avr-isp-prog...t-10-to-6-.html

This might be the easiest option if you feel so inclined.

Best of Luck,

-Justin

Oops the genders are backwards on that board nevermind.... but you get the jist of it.

-Justin

*Have a lab tech help out with making this adapter. Chances are he's got the parts ($.50 parts) and it would take him two seconds)

Link to comment

Justin,

I attached a wiring diagram and a flow chart, does this make sense to you? I don't have specs for the splitter I'm going to use, but i will shortly. It's pretty rough, but just wanted to give you an idea of how I'm setting this up.

-Jim

* also saw in your profile that you go to UofW ... lol, had to put something in to cite you :)

Link to comment

Hey jmt6009,

I'll get back to you Sat morn. School's kinda busy till then. With regards to ISP connection, that's why I was saying its not fun :) cause it either works, or it doesn't.

Two things to help:

(1): There is a troubleshooting guide in ISP the manual. P.27 may be helpful.

(2): Get a DMM that does the 'beepie' connectivity status. Use it to confirm pin locations.

Like I said though, this is the lame part, cause its hard to troubleshoot. The ISP is a snap though once this stage is over.

Talk to you Sat.,

-Justin

*What school are you at?

Link to comment

Justin,

Sound great, actually... Saturday will be a huge work day for me (working on the design project all day) so i'll probably ask you a question or two... lol. I'm a Mech. Engineer major at The Catholic University of America in D.C. and next year I'll be doing my Masters at the Naval Postgraduate School in Astronautical Engineering :).

-jim

* Over at NPS, they use simulink instead of LabView.. :(, I'll have to try and persuade them otherwise.

Link to comment

Hey jmt6009,

In my opinion, Simulink is generally a better mechanical engineering tool set. LabVIEW generally involves systems that rely either on-

a) a lot of electronics/compSci

or

b) a lot of expensive (but worth it :) ) NI hardware

Go with the simulink, its generally better served for the mechanical engineering stuff. Plus bosses never recognize or appreciate LabVIEW block diagrams, but they always seem to gawk at a nice Simulink model.

A quick side note to this opinion:

ME 'mechatronics'-type courses that teach with packaged boards (i.e. everything is bolted, soldered and buffered by some slaving TA), these courses have No business using MATLAB to control hardware. If they disagree, ask them how truly 'convenient' it was to go with the MATLAB in the first place. Also ask them how much they are really teaching their students about the hardware they're controlling. Typically this decision is made out of a lack of product awareness, and the students suffer as a consequence.

Just my two cents.

-Justin

*Awesome Side-Topic: LabVIEW-Solidworks Mechatronics toolset!!!! http://zone.ni.com/devzone/cda/tut/p/id/6183

- It is in Alpha right now, so its a free download. what will they think of next... Tell your friends!

Link to comment

Justin,

I'm trying to set up the programmer, but i keep getting an error STK500II, there seems to be a short circuit on the ISP connector, MOSI and SCK lines seemed to be short circuited.

Should i just keep going at it and trying to fix the wiring, or is this a common error?

*** Whoops, swtiched some wires, now it's blinking orange.. :(

* ha, this will become an hourly update... Fixed it.. no more blinky orange.

* Ugh, can't read the flash from the chip in AVR? The led is solid orange.

* Okay, got the progammer to work. Reads and Writes the flash memory just fine (had to fix the ISP freq, and it worked.)

So... now what do i do? lol.

-Jim

Link to comment

Success!!

I am glad to hear you got the ISP hooked up. That part can be very stubborn (but is smooth-sailing afterwards).

Now onto the trials. Try trial one, I've precompiled the .hex file for you (for a 324P @8MHz). Use the AVR ISP window and load it into the flash, then check if it toggles the pins on port A (it should :)).

Let me know how it works out.

-Justin

Link to comment

Justin,

So I've come to realize after opening up the computer that was given to us by the company who made our Radar, that the serial port on the back isn't actually connected to anything! So, do you think it would be possible to get a serial to USB cable and use that for the board? Would there be some issues with the program or would it still work okay.

-Jim

* I definately broke some fingers btw

edit: i dug deeper and pulled out the motherboard... Got the serial port. NVM crisis adverted. The guys who put the computer together just decided to not connect the serial port on the back of the case to the one deep in the box. :P

Link to comment

Justin,

So i tried the test 2. I programmed the chip, connected the serial cable, and ran labview. I wasn't receiving anything in the inbox. Should I have taken any other steps other than simply programming, plugging, and hitting go?

Also, i took a shot at the third test. My scope showed the squarewave (with some overshoot, that shouln't be a problem should it?) but i wasn't able to manipulate it with labview. Perhaps there is a problem with the serial?

-Jim

* Also, after going through some of my system settings, i noticed that the bits/s on the com1 port can't be set to 56000 like you have in the code/labview. Its currently set at 9600, and the closest to 56000 is 57600.... could that be an issue?

Link to comment

Hey Jim,

Serial Adapter ($7) : http://www.newegg.com/Product/Product.aspx...N82E16812156003

*Drivers and Manual are at sabrent.com. I have used it extensively, it works well.

A Few Notes

(1) 56000 should work, it is a standard rate. If it isn't for some reason, go into the project file and change the baud to 9600. then recompile the hex file and use that for your chip.

(2) I checked and the board is setup for a standard rs232 connection. Check that you do not have a 'null' serial cable. To check this, confirm connectivity with the dmm between 'Pin2' on both ends of your cable. If there is connection it is a standard cable(this is good). If not, then pin2 on one side connects to pin3 on the other (nullmodem, not the right cable :( )

http://en.wikipedia.org/wiki/Null_modem

(3) A wiring schematic for your devboard is on sparkfun. this may help in your debugging. In the doc, they mention an rs232 'jumper' J1. Confirm that the TXD0 line on your chip (TXD0, or PD1) is wired to the rx pin on the RS232 chip (see attached). the pin is called 'rx' on the chip with respect to the host pc (i.e. the host pc receives on this line. )

http://www.sparkfun.com/datasheets/AVR/avr-p40b-8535.pdf

(4) Trial_3 will not work if Trial_2 does not work. your prob is in Trial_2.

(5) The overshoot is most certainly from an uncalibrated scope probe.

With regards to the code not working, try the following steps:

(1) Check that the 'tx' pin on the chip actually sends out a digital signal. if not the code is wrong :( . But this shouldn't be the case.

(2) Check that your computers serial port works. on the serial cable, put a wire from pin2 to pin3 (i.e. connect rx to tx). with this configuration, your computer is sending to itself. Try a labview script that outputs some string. If your computer is working correctly, it should receive the same string.

Best of Luck and keep me posted,

-Justin

Link to comment

Justin,

I just ran a check to see if my serial port is working, and it does. I did a simple read and write from labview by shorting the pins on the cable and it worked.

Hmm... the code labview used had a rate of 9600. I edited the code in AVR studio, and built the new .hex file but nothing. I'm wonedering, should i be connecting any of the serial ports ( the tx or rx) to the main chip? Right now there is no wiring on my board other than my modified 6 to 10 pin adapter.

-Jim

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.