Showing posts with label Arduino. Show all posts
Showing posts with label Arduino. Show all posts

Saturday, August 11, 2012

Graduate school and xbee HOWTO

After many months applying for jobs and trying to figure out what I'm going to do next, Holley and I have both decided to go on to grad school!  I'll be posting about my ventures into the world of electronics design here starting with today. A part of my graduate project is going to deal with wireless communication and mesh networking.

That being said, I picked up a couple xbee modules and USB adapters to play with and get familiar with using them. Being a Linux nerd the majority of my time is spent trying to figure out how to make Windows solutions work in the Linux realm. Yesterday was no exception.




Here we have the xbee 900 pro digimesh something or other. It works on the 900 MHz band and claims a  range of up to 6 miles. Wow. That's way overkill for my needs but that is what was laying around the lab to play with. To my understanding all of the xbee products pretty much work the same with a few minor differences. I'll figure that out later down the road. First task is to get them talking.



I picked up two of the USB carrier boars along with the RF modules just so I could get them talking via USB and not have to worry about programming at first. After doing a little research I knew that getting them to work under Ubuntu wasnt going to be plug and play. The picture to the right shows the inhouse board the department made as well as an evaluation board from Digi.com. both work in Windows using X-CTU at a baud rate of 4800. X-CTU is the software utility that Digi uses to connect to and configure the xbee modules. Getting that up and running is a must if we want to do anything.



There is no Linux alternative to X-CTU so my first thought was WINE. Keep in mine I'm not particularly fond of WINE. It works sometimes and most of the time it doesn't. For this particular situation it does with a great deal of modification. I'm not going to pretend that I knew what to do to make U-CTU work but my googling skills are top notch. The following sites don't necessarily provide the working solution but go a long way to help piece together one that does. 


The problem with the wire.less link is that /dev/ttyUSB* is owned by root. So unless you run WINE as root all the time (dont do that) then you have to change the permissions of the device every time you plug on in. It possible and only requires one command but its a pain to remember all that. This is where the second link comes in. Its possible to set rules for specific devices. When they are plugged in you can mount them with a special name or in a special place or some other more complicated things. These are called udev rules. They reside in /etc/udev/rules.d/ . The hard thing is figuring out how to write these rules so that anytime you plug in an xbee it makes it readable and writable by users other than root.

Lets start with the easy stuff. First you want to install WINE if you don't already have it. The software manager of your distro will have it so go get it.

Nect go download the X-CTU installer from digi.com. Heres the link that I used.

Open up some terminal and from your home folder

cd /.wine/dosdevices

ln -s /dev/ttyUSB0 com5

ln -s /dev/ttyUSB1 com6

ln -s /dev/ttyUSB2 com7

ln -s /dev/ttyUSB3 com8

Those steps are literally cut and pasted from the wire.less link. What they do is link the COM ports windows normally uses to the /dev/ttyUSB ports we use in Linux. So when X-CTU goes looking for COM5 its directed to /dev/ttyUSB0 which is where it needs to be looking in Linux.

Now go find that .exe installer file we downloaded. Right click on it and set the permissions to executable. Then double click on it and let it install. It should do it automatically if you installed WINE correctly.

That was the easy part. Now we need to make it to where the user can go find and use /dev/ttyUSB whenever one of these devices is plugged in. I'm big on changing permissions as little as possible. Its easy to screw something up or create a security problem you don't even know about so I only want this to change permission when an xbee is plugged in. Otherwise leave it alone.

First thing you need to find an unique id to the ftdi chip that runs the USB converter.. This allows the computer to recognize the specific device the rule is for and not just blanket the rule over every device that's plugged in. I chose to use the vendor ID but you could just as well use the product or serial ID. I actually started with the serial ID but it would require an additional line be added to the rules for each different board. This is the most specific and secure but the least convenient. 

Open up a terminal and

udevadm info -a -p $(udevadm info -q path -n ttyUSB0) | egrep -i "ATTRS{serial}|ATTRS{idVendor}|ATTRS{idProduct}" -m 3

Write the values that come up. My idVendor was 0403. If yours is different youll need to change that in the rule.

So next we want to create the rule file. In the aeturnalus link they names their rule file 10-ftdi.rules. After doing some reading I saw it was recommended to name the rule file with a letter first so it is read last and overrides any previous rule. This makes sense due to the fact that the computer would read files starting with numbers first. So the next line is slightly different that what is seen in the aeturnalus link. 

Open up a terminal and

sudo touch /etc/udev/rules.d/ftdi.rules && sudo chmod 644 /etc/udev/rules.d/ftdi.rules

This is two commands in one line. it creates the file as well as modifies its permission. Next we want to add out rule to the file. Ubuntu uses vim and kubuntu uses kate to do text editing so pick your flavor. Im using kubuntu at the moment so

Open up some terminal and

sudo kate /etc/udev/rules.d/ftdi.rules 

This should open up a graphical text editor with a blank sheet in front of you. Don't panic. We just created this file. There shouldn't be anything in it.

cut and past this line in the file

KERNEL=="ttyUSB?", ATTRS{idVendor}=="0403", SYMLINK+="XBEE", MODE="0666" 

If you idVendor was different you'll need to change that here. 

Finished. Thats it. Now every time you plug into the usb port with a xbee through an ftdi chip it should set the permissions so that X-CTU can read from it. Here's a final shot of my Linux laptop communicating to my windows machine through a pair of xbees.


Friday, December 9, 2011

IT'S ALIVE!!!!

Yeah that title is cliché as all get out but deal with it. :-) Currently I'm excited that the projects not dead. That sentence needs a little back story. Last week (that time I should have been studying for finals) I got everything hooked up and ready to go with the motor drivers and Boarduino sled I constructed to hook all those motors up in a cleaner manner. I eventually got enough spare time to get it all hooked up to the CNC and with bated breath to see if it would work. Yeah I spelled that right too! I googled it. Anyway, the whole thing went to hell as soon as I gave it the command to move any of the axes. The motor were skipping steps like crazy. There just wasn't anything that was going to make it all work.

I didn't throw anything. I didn't even get super upset. This project has been going on for years. Literally. Its just another hurdle in the road I told myself. So I left the garage and started looking for the solution. The Gecko g540 is probably the most recommended motor driver  over on CNCzone.com so thats where I started. Ahren over at CNCRP has a kit that comes with everything to fit the need I was having.

http://www.cncrouterparts.com/3-axis-electronics-kit-p-74.html?cPath=22

For the small price of $520 the quick and easy solution could be mine. Right? Well no. Since Ive spent the majority of my project fund on the table itself I don't have enough left over to purchase such a fine piece of equipment. More on that later though.

Back to the drawing board I went. (another cliché phrase, is this guy kidding?)  The RepRap stepper driver V2.3 that I've built and am using is built around the Allegro A3982. Not much information is out there about the max specs of the v2.3 driver boards but Allegro provides specs for their chips so I just assumed that the circuit was built to utilize its capabilities.

"The A3982 is a complete stepper motor driver with built in translator for easy operation. It is designed to operate bipolar stepper motors in full- and half-step modes, with an output drive capacity of up to 35 V and ±2 A. The A3982 includes a fixed off-time current regulator which has the ability to operate in slow or mixed decay modes."

Hey I've got four, count them four, of these little drivers and I planned on frying one in the process anyway. After frying a HobbyCNC driver back in the first days of this project Ive come to expect to break a few things from time to time. So I scrounged up the biggest laptop supply I could find, cut the end off of it, found another old ATX power supply, cut the end off that too. Then I wired it all together and gave it a go.


After all that you're wanting me to say it ran perfect and I went on to cut something out or anything spectacular. Well not exactly. It bound up but it did have moments where it ran like it should. Even after cleaning the screw, the rails, and a light WD-40ing, it still bound in places going at the G0 rapid linear motion speed. At the slower G1 speed it did much better. This signifies that the motors are at the edge of their performance curve. Fortunately, Im still only running them at a fraction of what their capable of. Currently Ive got a 20v 6A power supply. Meaning that if I can get a hold of one closer to 35V it should make enough difference to get back on track to hit that dead line.

 

For now, enjoy this video of my latest Rube Godlberg project that knocks over a can of WD-40


Saturday, October 22, 2011

Ardunio GPS on the CHEAP

I'm still waiting on money to get straight before I go off and purchase anything else for the CNC. I've got about 300-400 more to go on the table and then Im going to have to figure out the electronics I've already got. I'm sure they are going to need repair and Ill have to navigate my way through the software. That's all for another day.

I get antsy when I've got nothing going on in the project realm so I went ahead and spent 20 bucks on a Pharos 500 GPS. Its one of those stamp sized units that came with Microsoft's streets and maps software...I think. Anyway I've got a couple Arduino Mega 2560 boards and since the 500 natively outputs in a serial fashion it was easy to communicate with..

I say easy but it took me some tinkering. The mega has several serial communication pins and if you hook the GPS up to the main one, it trips up the Arduino on start up. So you have to (well I did, I dont guess you have to) unplug the GPS and then plug it back in after you get booted up. The solution to this is to move to one of the other serial pins and just edit the code. Ill post a follow up with the modified code and a picture of the modified receiver.

Modified receiver? Yeah! That's how its done. Everything Kuztoms! No for real I had to break it open and solder pins to the board to make it bread boardable<-- Spell check says Im making that word up].

All in all the project has been a success. It was relatively cheap and  filled that whole in my boredom. So check it off the list. Where can I go from here? I'm thinking a reverse geo-caching project but that will have to be another day.

Sunday, October 9, 2011

Competition motivates me!


I wasn't planning on working on the machine today but I was inspired by one of the other members on CNCzone. KriegKuts is in the process of building a FLA-100 as well. Dude's Build Thread can be found at the link provided! The rail system I set up to drill the holes for the X rail needed to be modified for the 6 inch Y rail. Basically instead of the small bolts and wing nuts I had to use a C clamp. Not as elegant but it worked. Today I didnt have the help of my dad so having a plethra (<---Nice word huh?) of C clamps of all shapes and sizes to hold the rail as I drilled it. I skipped the mid size bit this time and went straight from the center bit to the 3/8 bit.

I was going to stop here for the day but then I realized that the Z axis only needed 6 holes to be mounted. I didnt trim the rail or the supporting 8020 extrusion so pretend you don't see that. As for going straight to the 3/8 bit.


 



You can see it turned out fine. Im sure it shortened the life of the bit but after today Im done with it and its paid for itself. I bought 2 and only needed 1. That means Lowes gets to have one of their nice $11 kick ass bits back Im am so amazed that Im able to work with raw steel and get precise enough results to even slide the rail into the extrusion. 

Without adjustment of anything I checked the height of the bottom of the Z rail on both sides. Less than 1/16th of an inch different. Thats nuts. Now Im off to check my bank account and see what I need to do to pick up the power components.

$310 plus shipping. Ouch. But that's all that stands between me and moving on to the electronics....which Ill be salvaging from my last build. Arduino + DIY Reprap drivers + some creative thinking. Thats the teaser of the day.