91.548 home
lab 3 html
papers Johnny 5 pdf
ARVP pdf
RDB3K pdf
mtg 3: laser cutter & HPGL
lab 2 html
HPGL manual pdf
mtg 2: intl ground vehicle comp
mcp docs
igvc site
mtg 1: LogoChip & Bus Devices
metacricket paper html pdf
UML305DEV board assembly pdf manual pdf LogoChip
  download html
  start pdf
  intro pdf
  tech pdf
  lang ref pdf
  PIC 16F876 pdf
lab 1 html
resources student pages project movies ikonboard LogoChip

LogoChip Bus Version

The LogoChip virtual machine has been extended to include background bus receive. Also the bus transmit (bsend) primitive works properly now.



Download the LogoChip ZIP archive here.

After unzipping, go into the "vm" folder and run the "ASM-LOADER" project. Click on the "assemble filename" button. You should see a display of the code size in the main window.

Next, hook up your LogoChip to the serial line, and power it on with the Run/Stop button held down. You should not see a boot flash.

Now, click the "load-asm" button on the ASM-LOADER screen. The button should stay in a "clicked down" state while the code downloads. You should also be able to see the green serial status LED on the UML305DEV board flashing during this process. If it completes without complaining, it worked.

Power on your LogoChip again, this time not holding down the button. You should see the boot flash. You can now run the "LC LOGO" project from the ZIP archive. Do not use the originally installed LC LOGO project anymore.



Port B0 (pin 21) acts as a bus send and receive pin.

Note that the bus requires a 1K resistor pullup to +5v to work properly. If you are using LogoChip as a bus slave and a Handy Cricket as the bus master, you do not need to add the pullup, because the Handy Cricket already has it.

On the other hand, if you are using LogoChip as a bus master to talk to some other bus devices, then you need the pullup.

The following new Logo primitives are available:

bsend -value-
Bus send. Transmits a bus word. Low 8 bits are the data component. If the 9th bit is a one, then the word is marked as a command. For example, bsend $110 sends the decimal value 16 marked as a command word. Note: If the LogoChip is a bus slave, it should never send command words. Only the bus master should send a command word.

Reports the last bus word received by the LogoChip. Bus reception is active in the background, even when the LogoChip is not running a program. The low 8 bits of the value are the data component; the 9th bit is the command/data flag (1 for command). Reading from brcv is non-destructive; it will keep returning the last value that has been received each time you ask.

Note: bus reception is disabled when you are downloading new code to the LogoChip. This includes command line interactions, which actually are tiny code downloads (followed by code runs). So, for example, if someone is sending you bus commands, and you are trying to display them by typing print brcv, this will intermittently fail. Instead, try something like loop [print brcv]. Once the print loop is running, it won't lose traffic.

Reports true if a new bus word has been received since the last time you asked it; otherwise, reports false.

After newbus? reports true, if you ask again, and a new bus word has not been received, then it reports false. So, for example, to dead-wait until a bus word arrives, you could say waituntil [newbus?]. This would be a typical usage.

The LED-flash command is now simply flash. I got tired of typing nine characters to get some LEDs to flash. The old command for flashing no longer works.



You must not write bit 0 of the Port B Data Direction Register to a zero. If you do so, the LogoChip will crash the bus, and no bus communication will be possible.


Sample Project

In this sample project, a Handy Cricket is the bus master and the LogoChip is the bus slave. There are three primary steps:

  1. Wire the Handy Cricket bus to the LogoChip bus.
  2. From the Handy Cricket, send a bus command.
  3. On the LogoChip, receive the bus command and do something when it is received.

Step 1: Wire the Handy Cricket Bus to the LogoChip Bus. This is easy if you build the cable properly. There are three sub-steps here: (a) inserting the crimped wires into the bus plug housing right-side up and not upside-down, (b) getting each wire into the correct location in the four-position bus plug, and (c) stripping and tinning the open wire ends so that they may be reliably inserted into the solderless breadboards.

Step 1a: Inserting a Crimped Wire into the Jack Housing. The figure below shows top and end views of the crimped wire and a 2–position housing. Notice the tiny locking leaf on the edge of the connector "U". This leaf should be visible through a slot in the plug when it is inserted. Look at the AFTER INSERTION drawing specifically. Notice that you can see the locking leaf through a slot in the plug.

Step 1b: Inserting the Ground and Bus Signal Wires. The photograph shown below (enlarged for clarity) shows the correct position of the black ground and white bus signal wires in the 4–position bus plug. The bus plug is held so that the locking leafs can show through. From left to right, with the wires coming in from the bottom, the order is: black wire, empty slot, white wire, empty slot.

Step 1c: Stripping and Tinning the Wires. This step prepares the wires for reliable insertion into the solderless breadboards. Strip about 1/3 of an inch (about 0.5 cm) of insulation from the ends of the wires. Then twist each wire end (individually) into a tight braid. Then apply solder to the exposed braid, letting it infuse into the tiny wire strands, making a solid single bundle. Clip any excess solder ball from the end of the wire.

The cable is now ready to use! Insert the plug the into the Handy Cricket bus jack. Insert the black wire a ground in your LogoChip circuit. Insert the white wire into Port B0 (pin 21) of the LogoChip.

Step 2: Send a Command Word from the Handy Cricket. We will choose device class ID of $80 (decimal 128) for our example. So the Handy Cricket needs to send $80 marked as a command word to the LogoChip slave. It does this by sending $100 plus $80 or $180.

For demonstration purposes, put the command bsend $180 beep into the Run This line of the Handy Cricket, and download. Now each time you press the Cricket's Run/Stop button, it will send the command word $80 and beep.

Step 3: Receive the Command Word from LogoChip. The LogoChip should wait until a word comes in on the bus, and then check it to see if it's the magic code $180 (i.e., the value $80 marked as a command). If so, it will flash.

Code to do this is:

to slave
  waituntil [newbus?]
  if brcv = $180 [flash]

Run this code on LogoChip. Now, press the button on the Handy Cricket. LogoChip should flash!


Your Turn

You now have the tools required to create your own LogoChip-based bus slave. For more information about typical protocols, see the documentation for the LED Number Display and the Handy Cricket Bus Overview.


Doing Serial with the LogoChip

To send a byte out the LogoChip's TxD pin, use the built-in keyword send .

Use the procedures below for serial receive:

to receive?
output $20 and read $c

to getchar
output read $1a

The receive? procedure returns true if a serial char is waiting.

The getchar procedure returns the waiting char. getchar blocks if no character is available.

Changing Baud Rate

Two registers control the baud rate: SPBRG (address $99) and another reg at $98.

To switch to 9600 baud, execute:

setbit 2 $98

This puts the PIC into high speed mode, and the default setting in the baud rate register (which happens to be 129 decimal) is good for 9600 baud.

Note that the LogoChip will revert to 2400 baud between each command entered at the control center.


Main LogoChip Site

Here is the main site for LogoChip.
Last modified: Tuesday, 03-May-2005 12:17:31 EDT fred_martin@uml.edu