'Logochip' Category

Minimalist Arduino

March 15th, 2009 March 15th, 2009
Posted in Logochip, Uncategorized
No Comments

  There is something to be said for the processes of reducing a set of objects or functions down to their lowest common denominator but I think what has really driven me to do this is I am too cheap to go out and buy an Arduino Decemila every time I want to built a new project. But really after doing quite a bit of business with the Logochips I think I understand how important it is to try to design “The little engine that could” do almost anything on a budget. This could be cool, and time will tell what all can be done with it.

   So here are the basics to a build your own Arduino clone with a hand full of parts that may cost you no more than about six dollars.

  First there is the microcontroller, the brain, the Atmel ATmega168-20PU(costs about $4.00). I should mention here that you need a way to program the bootloader into the Atmel chip. If you have a friend like Keith who will lend you his USBtinyISP and an Arduino Decemila it makes it real easy. Other wise buying one of each might be good if you plan to make a lot of clones.

 Next you need to provide the chip with a good 5 volt supply. I suggest the LM7805 and a couple of small capacitors(costs about 50 cents) to regulate just about any voltage down to a nice safe 5 volts for the microcontroller. If you are making a project that already has a 5 volt supply like an old computer power supply you can use that or a set of 4 rechargeable batteries (AA or AAA) works well for those portable projects.

  Now the brain needs a clock to keep it on time. That would be this, 16 megahertz crystal resonator (costs about 40 cents). Your probably reading this post on a laptop or desktop computer that is screaming along at 1 or 2 gigahertz well, just slow down, take it easy, 16MHz is just the right speed for the serial communications between the Arduino and your computer.

  One more thing. The brain has a tendency to fall asleep. You’ll need a 10,000 ohm resistor (cost 2 cents) to pull the reset pin up to 5 volts and keep the Arduino running. When you download a program from your computer this reset pin gets kicked to tell the Arduino ” HEY I got somthin for ya”.

MinimalArduinoPic

MinimalArduinoPic

   OK now in the picture here the Arduino clone circuit described above is on the left side and on the right side is another small chip CD40106 which is called an inverter. It and a couple of resistors and a capacitor will condition the signals to and from your computer when your downloading a program to the Arduino. When your done programming you can remove these parts and the Arduino will run by itself. There are three lines of communication that the Arduino needs to successfully download a program, RXD receive data, TXD transmit data, and DTR data terminal ready. The DTR is the one that kicks the reset pin and makes the Arduino gulp down a new program.

minimalistarduino

  So here’s a schematic drawing of the circuit in pdf and also data sheets for the LM7805 and the CD40106 and the XTAL resonator thingy.

lm7805     cd40106     xtalres

  Of course none of this addresses any of the many things you can do with the Arduino but that’s another story for later.

Tom

Infrared Transmit and Receive with a Logochip

November 30th, 2007 November 30th, 2007
Posted in Logochip
No Comments

    When ever I find an easy way to do something I just have to make a record of it. There are some projects where you might want to do something wireless with the Logochip. This little circuit makes it pretty easy.

    First an explination of the Radioshack 276-640, the IR Receiver Module. It will receive signals from an IR(940nm) LED that is oscillating at 38killoherts. So if we want to send a series of 1’s and 0’s we modulate this 38KHz signal on and off.

    Fortunately the Logochip can produce the 38KHz signal and modulate it with very little effort from the software.  We’re going to set up the internal timer module to produce the signal and set up the serial UART to modulate it. So here let’s look at the schematic.

            LogoIRtranceiver

   This schematic shows the Logochip circuit to the left and the IR transmit and receive circuits to the right. There are two transistors involved in the in the transmit. The one that drives the LED is driven by the timer output PORTC bit 2 which is producing a 38KHz square wave. But most of the time it is being held off by the other transistor which is being driven by the transmit pin (TX) PORTC bit 6. Now when you tell the serial port to transmit an 8 bit byte the serial data comes out of the TX pin and modulates the 38KHz signal on and off to the LED.

   On the receiver side (this is really easy) the Radioshack part is simply hooked up to the 5 volt power and ground and the output signal runs right into the receiver input (RX) PORTC bit 7. I put a resistor to ground just in case the output drifts. That’s it.

    Here’s a picture of my bread board. IRlogoProtoBoard . The transmit LED and the receiver module are pointing straight up and I just help my hand above it to reflect the signal back. I can’t wait to use it in something.

    So here’s the Logochip code. I hope I commented it well enough for everyone to follow.

                      TextPage

Have fun…

Comm Port Error Handeling

November 7th, 2007 November 7th, 2007
Posted in Logochip
No Comments

If I were to describe the proccess of implementing a sreial port communication with a microcontroller I’d say It’s a shot in the dark. There are a fairly large number of variables that come into play when data is transmitted and received. I just wanted to touch on error handeling here just as sort of note to my self if nothing else. Presuming you get the baud rate and the number of bits set right and you are able to get the basic communication working there are a couple of things that can still happen that will put a damper on the whole thing.

Framing Errors

If you send a whole string of data to a microcontroller and the controller software isn’t paying a lot of attention to the comm port one of the things that can happen is called a framing error. In the PIC18F2320 chip there is the “rcsta” (receive status register) which is at address $fab. Bit 2 of this register will go high on a framing error. The best resolution for this error that I have found is to go ahead and read the data from the “rcreg” receive register but keep in mind that it may be bad data.

Over Run Errors

Another kind of error you can get is called over run error. This can be a serious problem because it will cause the reciever to stop working until the problem is resolved. Bit 1 of the rcsta will go high (1) on an over run error. To resolve this error turn off the continuois recieve bit (bit 4) of the rcsta (set it to 0) and then turn it back on (set it to 1). This will flush out data that is held in the receive buffer and reset the reciever to run again.

CORRECTION It will flush out the receive buffer but it will not clear the error. So don’t keep doing it in a loop because the error will clear only after the next byte is received. If you keep reseting the receiver it will never receive the next transmition.

So here is a code example for the Logochip to handle the comm port:

;CommErrorTest.txt

constants [
 [rcreg $fae][rcsta $fab]
 [spbrg $faf][pir1 $f9e][txsta $fac]
 [txreg $fad][t2con $fca]
  ] 

global[ comand ]

to powerup
 prs “CommErrorTest.txt”
 write spbrg 25  ; sets baud rate to 19200
 write rcsta $90
 write txsta $24
 write t2con 6
end

to startup
 loop[
  if testbit 1 rcsta [ ;check overrun Error
  clearbit 4 rcsta
  prs "overrun"
  setbit 4 rcsta
  ]
  if testbit 5 pir1 [
   setcomand uart-receive
   print comand
   ]
 wait 10
 ]
end

to uart-send :n
  waituntil [testbit 1 txsta]
  write txreg :n
end

to uart-receive
 if testbit 2 rcsta [  ;check frame Error
  prs "framing"
  ]
 output read rcreg
end

Extra Memory EEPROM for the Logochip

April 15th, 2007 April 15th, 2007
Posted in Logochip
No Comments

Using the lab notes from Prof. Robbie Berg I hooked up a memory chip to a Logochip using an I2C interface. So if somebody would want their Logochip to remember a bunch of numbers like a data pattern or say an audio track this could help. It could also be helpful if you wanted to use another device that had an I^2C (also called”2 WIRE”) interface. Memory is saved when the power is off too. The PDF formatting of his lab notes kind of screwed the line feeds so I tried to tidy things up. But it’s real easy to hook up. The part only costs a buck. You can paste this code in, load, and go. Might be a good thing to put in the wiki.

  LogoEEPROM 

Logo code for reading and writing data to a 24LC64

The Logo code below (also stored in the course conference is the file calledeeprom.txt) contains the procedures needed for a LogoChip to be able to write and read data to and from a 24LC64.

To write a byte of data to the 24LC64 use write-eeprom <address> <value> where <address> is an integer from 0 to 8191 and <value> is an integer from 0 to 255. For example try

   write-eeprom 100 57

 This command stores the number 57 in memory location 100 in the 24LC64

To read a byte of data from the 24LC64 use read-eeprom <address> where <address> is an integer from 0 to 8191 and <value> is an integer from 0 to 255. If you try

   print read-eeprom 100

you should see the number 57 print in monitor window.
Here’s the code:

 

 

  TextPage

Just stuff all this in your program somewhere or put it in a library and include it in you code.

More Than One LCD…LCD…LCD

April 12th, 2007 April 12th, 2007
Posted in Logochip
No Comments

This is in response to a previous error and also to make sure that parallel data lines to multiple LCD modules would work. I haven’t built the whole circuit but enough to conferm that it will work. Earlier I posted a schematic if a single line LCD module that had pin 3 grounded and it should have been tied high. Here’s a picture of what I wired up:

        WD-C2401P   

And here is a schematic of a Logochip and 3 LCD Modules wired up to it:

                     Schem

And here is some code that sets up the Logochip and initializes the LCDs and prints aome characters on each LCD.

                        TextPage   

Here are some links to more useful information on the LCD Modules

        A real crummy copy of the manule (LCD-111)

       More info than you want to know about the LCD controller

      A site with other applications using this LCD display

Logochips as Slaves

March 7th, 2007 March 7th, 2007
Posted in Logochip
No Comments

I know it sounds awful in this day and age to be using slaves but Logochips don’t really mind that much. There are a couple of groups that are considering multiple Logochips and here is a suggestion of how that can be done.  You can do something really easy by using the built in serial comm ports (portc 6 and portc 7). Here’s a brief schematic.

                                Schem

The program that goes in the master is slightly different than the program in the slaves in that the slaves have to keep their mouths shout until spoken to by the master otherwise the master won’t know which slave is doing the talking. So here’s the Logochip software programs.

   Master:    Master1                   Slave: Slave1 

 TextPage        TextPage

PWM variable control of lights and motors

February 24th, 2007 February 24th, 2007
Posted in Logochip
No Comments

Pulse Width Modulation (PWM) as it is used in electronics is the greatest thing since sliced bread.

PWMschem 

What it allows us to do is regulate the flow of energy with out wasting so much of it. In the early days if you had a 12 volt battery and you wanted to drive a 6 volt lamp you could use a transistor to regulate the voltage down to 6 volts but half of the energy was wasted as heat in the transistor. PWM uses the adveatage of time. A 6 volt light buld or a motor or many other devices can actually run at 12 volts just not for a long time. So we take advantage of that by pulsing. For instance, having the lamp on for 1/2 of a second and then off for 1/2 of a second would be like delivering 6 volts for one second. Of course you could call that blinking but if you speed that up about 100 times and do it at a frequency of 100 Hertz it’s so fast you can’t see the blink. Whats more the filiment of the light buld doesn’t have time to heat up to the 12 volt level so it dosen’t know the difference eather. It thinks its running at 6 volts. Caution - results may vary depending on the type of lamp your using but negative effects can be reduced by adjusting frequency and duty cycle (on and off time).

What about the transistor? Yes there is still a transistor involved but idealy it is working just like a switch. When it’s off there is no current flow and no power lost. And when it’s on all the current goes through it to the lamp and none is lost in the transistor (switch).

Here are some cleaver links I found that might help.

http://www.cpemma.co.uk/pwm.html

http://www.uoguelph.ca/~antoon/circ/pwm555.html

http://www.acroname.com/robotics/info/concepts/pwm.html

Capacitive Proximity Sensing

February 23rd, 2007 February 23rd, 2007
Posted in Logochip
No Comments

      Here’s a neat magic trick for a user interface. It’s called capacitive proximity sensing. It can detect the presence of a finger or a hand or a body on the opposite side of a wall. This can be really handy when you want the observer to interact with something but have the interface be completely invisible.

ProximityMagic     

     The technique involves three parts: One, an oscillator circuit that uses a metal plate as the capacitor that effects the frequency. Two, a frequency divider that averages out all the garbage that might be picked up by the metal plate. and Three, a circuit that detects changes in the average frequency.

                                        Schem

 Here’s a rough schematic using a very simple circuit. In the schematic I have it lighting an LED but this could go into the Logochip or another circuit.

I have data sheets for the two Integrated Circuits used in the circuit here:

           the CD40106      and the CD4040

 

Logochip Xylophone

January 31st, 2007 January 31st, 2007
Posted in Logochip
No Comments

I’m getting the hang of some of this linking pictures and movies in blogs.

This is a Logochip driving a stepper motor and relay coil to play a xylophone.

xylophone1.jpg

Here’s the Logochip code that I showed you in class.

And a schematic of the drive circuit and motor.

And just for kicks watch the  video .

LCD Display

January 28th, 2007 January 28th, 2007
Posted in Logochip
No Comments

Well that was a challange. John gave one of the WD_C2401P LCD modules to me and I played with it till I got it to work.

WD-C2401P

Here’s the new code:
to startup
 write porta-ddr 0
 write portb-ddr 0
 cc $1C cc $14 cc $28 cc $4f cc $60 cc 1
 dd 32 dd 32 dd 32
 dd 72 dd 101 dd 108 dd 108 dd 111 ;Hello
 dd 32
 dd 87 dd 111 dd 114 dd 108 dd 100  ;World
end

to cc :xx   ;send a command
 clearbit 2 $f89    ;clear RS to write commands
 write portb :xx
 setbit 3 $f89      ;clock the command in
 mwait 2
 clearbit 3 $f89
 wait 1
end

to dd :xx  ;send character data
 setbit 2 $f89     ;set RS to write data
 write portb :xx
 setbit 3 $f89   ;clock the data in
 mwait 2
 clearbit 3 $f89
end