Sunday, September 20, 2015

Arduino Programming

     I have been playing with a multitude of options, programming tecniques on various projects to expand my knowledge of the Arduino programming environment.
     It has been a fustrating, but fun ride. I have master the shifter library that my grandson (Moose) found. I have successfully and reliably controlled up to 7 chained shift registers with a growing string of leds. I am going to tackle 7 segment displays and then move to controlling matrices reliably.
     I've spent a good amount of time making different patterns of 56 LEDs. Knightrider style, various chasers, a simulated VU meter, and a binary counter (which does not use the shifter library). Due to the amount of current it takes to drive all of the LEDs, I was also thinking about charlieplexing the LEDs when a large amount of them need to be lit. (Charlieplexing is the process of rapidly flashing the LEDs one at a time to give the illusion that they are on. The downfall of this, is they will not light up as bright.)
     I did find that charlieplexing is not efficient enough for large amounts of I/O. Multiplexing is better. Same effect, fewer wires.
     I'm working on getting the hang of working with binary arrays to make patterning easier, but also try to find ways to code that does not take lots of the Arduino memory. This will also help make charlieplexing easier to program.
     Another thing, is getting wifi projects working. The best I've got so far is to ping different websites.
     I've got arrays down pat, but still trying to grasp multi-dimentional arrays. They are a whole different animal. They are essentially arrays within arrays or arrays referencing other arrays. It gets nasty.
     I have gotten a 3d printer that is run by an Arduino. I have been learning how they crammed so much programming in such a small amount of processor memory. Also on how they created different files for sections of the program and it all work like one big program. This program that runs the printer is referred to as the 'firmware' of the printer. That is because this 'firmware' does not hold any pattern you want to print, but only interprets any g-code commands to it (via) usb and moves the printer accordingly. I will explain more about the printer in another blog.
     I can say now that I can do alot with leds on the arduino. Motor control is another endevor. I will likely get a motor control board like ramps to experiment with making robots. I can easily make lights do anything I want.

Saturday, July 25, 2015

Arduino Uno

     I got an Arduino Uno starter kit for the grandson (Moose) to learn electronics with. The Arduino is a microcontroller that uses a programming IDE called Sketch. It is very simular to C++. This has been an interesting ride so far.
     We started by playing an LED and getting it to dance as we saw fit. This taught us how to assign and control the ouputs of the Arduino.
     We then moved on to playing with an orchestra of 13 LEDs. Then we moved to playing with a seven segment display.
     This where things got messed up. The guide we were using had goofs in just about every program. I had helped Moose in figuring them out, but this was getting rediculous. I had Moose typing most of the code in by hand instead of copying the code from a pdf. This was to instil the syntax of programming. But most of the time when I couldn't find the error in the code, I resorted to the web for solutions or a whole other example code to use. This is how the rest of these projects went.
     The seven sevment display proved challenging as it introduced the use of functions. These functions are alot like the old familiar subroutines from other programming environments.
     We then moved on to a 4-digit segment display. That had just about used all of the I/O the Uno had. That is where the idea of getting the 74HC595 shift register to work. But, we had other playing to be had yet. This code was robbed from some forum online. As I also tried to get it to multitask 6 LEDs also.
     I had found that the Arduino does not multitask, as it does not have an OS, but only a bootloader to allow the Sketch programming. In order to "multitask", we had to ditch the delay(x) commands, (witch just tells the processor to wait for the specified time. It does nothing during that time but kicking rocks.) and start managing time. So, in doing that, I got it to drive the 4-digit display with a counter and flash 6 LEDs without skipping a beat.
    

Friday, April 17, 2015

Lego Minstorm EV3 mod

     Well, I have gotten a Lego Mindstorm  EV3 for the grandkids to learn programming. This is a start that will give them a very good start into this field. I have been playing with it for a few weeks now to make sure I get the hang of it so I can help them when and if they need it.
     While I've been tooling around with different bots, (and also some very cool machine builds like one that scans and solves a Rubik's Cube), I have been learning alot. There are two annoying aspects of the EV3: 1) Batteries don't last long enough. 2) There is no backlight. So, I set out to tackle these issues.
     There is a rechargable battery pack that is supposed to have longer life; I just haven't buckled down to get that, yet. I opted for a corded solution to help with some other projects I'm working on.
     I got two dead AA sacraficial batteries, about 3ft of 20ga electrical bell wire, a scalpel (knife or wire strippers will work), and an EV3 brick.
     I sat down and ripped the brick apart, got the display out, and started to figure out what I could put where. I was hoping to get an Indeglo backlight and slide it behind the screen. Nope, that was not going to happen this time around. Double-sided adhesive foam  is not known for coming apart. Plus I wasn't going to spend that kind of time on it atm. So, I opted to cut some plastic away on the left side of the screen cradle to make just enough room for two tiny surface mount leds I had laying around. This got interesting; as I was constantly in fear of slipping and scratching the lcd or breaking it entirely. I whittled away at the first notch (for what seamed like eternity). I got it done and the fitment of the led just right. I then started on the other one.
     Once I got both leds in place, I soldered the wires needed and left about a six inch tail for both leads. I powered them up to ensure all the joints were good. And Vola! I had light. I reassembled the screen into the housing being careful of the wires and the leds (Hot glue would have been good!).
     Now, I was on to find a good point to get power from off the EV3. I poured through schematics and probing the board. I tried the programming usb port, but nope. Not enough power there. I found that the full size usb port has a 5v supply, but I can't get to it to solder to it. The main board also doesn't seam to want to budge (More foam tape?). So, I'm going to install a surface mount transistor to automatically turn the LEDs on and off with the main power.

     Stay tuned... I'm not finished yet.