Sei sulla pagina 1di 9

What shall I do as my first circuit...

Published on 27th February 2010 18:27 By johntabb Well having played with PIC microcontrollers (the heart of the Amicus18) for a while, I am aware that if the circuit isn't performing as you expect, there are usually very few external indications of what's wrong. Obviously if something's VERY wrong, the circuit starts sending Smoke Signals, you tend to notice... but at other times, the circuit just looks insolently back at you and does nothing... or something completely wrong... I like to have either an LCD display or a Serial output connection to the PC so I can flag where the program is at choice times. Now I know what my first circuit is going to be... An LCD Display panel

Components Parts needed in addition to the low cost companion shield. 1 off Alpha Numeric LCD panel (recovered from an old piece of equipment) 1 off 220 ohm resistor (required to bias the display to make the characters visible) Ten short pieces of wire. Solder Soldering iron First of all I removed the old ribbon cable from the LCD panel I recovered from an old piece of equipment. If you look at the

diagram on page 243 of the Proton Amicus18 Compiler - Revision 1.pdf (You can find this under the help drop down menu on the Amicus 18 IDE tool bar. )(Also fig 3 here) you will see that you need to connect four Data pins from the LCD to the Amicus shield, plus three earth connections two power connections, an enable pin, a reset pin and a resistor to earth. My LCD has fourteen connection pads across the top left hand corner, these number Left to right, looking at the screen side.

First learning point - If you are going to use wires to connect things that are likely to move... make sure you use wires with several filaments in the conductor... single filament wire breaks easily when moved, multifilament wire is more flexible and less likely to break. Second learning point -If you are going to have a number of wires on your circuit board, try and use different colours, it makes fault finding much easier... In (fig 4) the three left hand wires are actually Mains cables and generally far too big for most electronics work, but they are easier to see in a picture. The Left hand red wire has a single filament, it is intended for fixed cabling and will break if fleced a number of times, the Black cable is intended for higher current applications and id stranded to make it easier to handle, but it also is intended for fixed cabling and is not considered to be Flexible. The central Grey wire is made with a large number of five filaments so that it is both flexible and capable of carrying high current., the rainbow ribbon cable has much thinner wires bonded

into a flat cable, each colour represents a different conductor or signal wire, and you may just be able to make out the thin filaments in the right hand red wire. This is low current low voltage cable intended for electronics work. Another source of multicoloured wire, is old computer cables, the cable on the right is an old serial printer cable. Again these conductors are multifilament and flexible. Story Time! Years ago we had a very enterprising young man at the computer club, who would try lots of projects, and he was very successful. But - he didn't know the two learning points above. He had bought a huge reel of Pink Single filament wire and was using it for every connection on his projects. Unfortunately It's not easy to tell one pink wire from another, so as he worked he was forever pulling on the wires to see where they went, with the inevitable result that wires would periodically break and parts of the project that used to work, would stop working. And of course its very difficult to know which pink wire needs connecting back to where! Back to the Project Having removed the ribbon cable and the excess solder, (fig 5)I first took the 220 ohm resistor and bent the leads at 90 degrees close to the body of the resistor. I then fed the two leads through the LCD printed circuit board (PCB) from the back, through holes 3 and 7. I bent the wire that came through hole 7 so that it covered pads 8, 9 and 10, on the back of the PCB I pulled the resistor down so that it's body didn't cover holes 4, 5 & 6. and soldered pad 3, 7, 8 & 9, leaving the hole on pad 10 exposed for the moment. I then connected a group of 5 wires into holes 10, 11, 12, 13 & 14 on the LCD ( I used a piece of coloured ribbon cable for this, ) (note when soldering the wire in pad 10, make sure you also solder the end of the resistor wire which is strapping pads 7, 8, 9 & 10 together/ using another piece of 5 wire coloured ribbon cable I connected one end of each wire to pins 1, 2, 4, 5 & 6 on the LCD PCB. (note, the white tape on the back of the LCD is to prevent short circuits between the LCD module and the Companion board)

The other ends of these wires were then connected to the Amicus shield as follows. LCD Pin to Amicus Pin 1 - Gnd. 2 - +5volts 3 (resistor) 4 - Port RB2 5 - Gnd. 6 - Port RB3 7 (resistor- strap to 8,9 & 10) 8 (resistor- strap to 8,9 & 10) 9 (resistor- strap to 8,9 & 10)

10 (res- strap to 8,9 & 10) with wire to Gnd. 11 - Port RB4

12 - Port RB5 13 - Port RB6 14 - Port RB7 (Check the connections to ensure there are no short circuit's or bad joints) Having installed the shield on the Amicus18 board I was then ready to program the Amicus18 board with instructions to make it run... (fig 6)

I will add the instructions (Program) at the end of this text. Whilst I was working I thought... why not include some programming to test the Amicus serial port. (we will see that in the program later.) As advertised the Amicus Board has a USB interface which emulates a traditional RS232 serial (COM ) port. in order to use this port we need to know what number the PC thinks it is. I had a look in the Control panel / system / hardware / device manager, and found the answer under the Ports (COM & LPT) heading. My computer thinks Amicus18 is COM7. Using Amicus Serial Terminal Plugin You can select the Amicus18 Serial plugin (fig 7) by either clicking on the Serial Com icon on the Plugin toolbar within Amicus18 IDE (fig 8), or by pressing F4 whilst in the IDE. The Serial Com (Communications port) plugin needs to be

configured to match the programmed configuration within your Amicus18 Program code (See Below). To configure the Plugin, choose File from the Serial Com plugin menu bar, and select New Connection, (Assuming your Amicus18 Serial port driver has been loaded onto your computer, you should be offered the option of selecting one of a number of com ports, (my computer offered Com1 and Com7 (Amicus18 Serial Com port)) Choose the Amicus serial port Next select the Settings option from either the File Drop Down Menu, or using the Settings icon below the menu bar. This will open a dialogue box, where you enter Bits Per Second 9600, Data Bits 8, Parity None, Stop Bits 1, Flow Control None. And the serial port configuration is complete, Once you start the program running you may have to click on the connect icon.

As you can see from the image in (fig 7) once you run a successful program you should see text within the serial terminal window.

The Program

(fig 9) Contains a copy of the code for this project, (an editable copy is included in the original article in the Amicus18 Web page). The LCD part Lines 1 to 6 begin with an apostrophe () indicating that the information is a comment and not a program instruction Line 7 configures the Serial port data speed and must match the information in the Serial Terminal Plugin. Lines 8 to 13 configure the Amicus18 Microcontroller where the LCD panel is connected. Line 16 is a user defined label used so the program can be made to run continually, Note this is one of a number of techniques which could be used. Lines 20, 26 & 32 cause the Microcontroller to delay for a period of time measured in milliseconds (1/1000s of a second). Line 22 causes the word Hello to be printed on the 1st line of the display starting at the 3rd Character position Line 23 wound normally cause the word World, to be printed on the 2nd line of the display, starting at the 2nd Character position However my recovered LCD Display is very odd, the first eight characters are considered to be Line 1 and the remaining eight characters are considered to be line 2 of the display. The display cost nothing so I can live with this If you buy a display it will normally be properly addressed as lines 1, 2, 3 & 4, depending upon how many rows your display can offer.

The Serial Part

Line 24 causes the Microcontroller to send Hello World out of the USB cable, into the computer where the computer treats the signals as if they came from a Com port Line 25 causes the microcontroller to send (Serial Message) and two special ASCII control characters 10 and 13 to be sent to the computer See (fig 10) the ASCII table can be found as a drop down plugin from the Amicus18 Plugin tool bar. Line 30 causes the words Test Message and three ASCII control characters to be sent to the PC If we look in the Serial Terminal we can see that line 24 causes Hello World to appear on the terminal screen (if toy look in the program (fig9) you will note there is also a space which is also sent to the screen, Line 24 causes the message (Serial Message) to be sent to the serial terminal, which displays these words as a continuation of the same line the ASCII codes 10 (Line Feed) and 13 Carriage Return, date back to mechanical type writer days and cause the next row os test to start one row down and in the left hand column. Line 30 prints Test Message and them line feeds and carriage returns two lines to cause a gap I have just noticed an error that should have been two carriage returns and one line feed but the terminal plugin has interpreted my commands correctly as I intended.

And Finally Line 35, tells the microcontroller to go back to the Label Loop which is on line 16, and causes a never ending repeat of the LCD messages and the Serial messages to be displayed. ---ooo000ooo--I hope this article has given you an insight into how simple it can be to send messages from your Amicus18 to the LCD and the computer. If you have any queries, please open a thread in the forum area for discussion. (Please mention this article so that everyone knows what you are talking about. This article was written in Microsoft Word, and exported to My web site because I couldnt work out how to include more than 5 pictures in an article. If anyone can help me, I would be pleased to try writing the article completely on the forum platform. I hope you enjoy working with Amicus18. and look forward to you writing articles at a later date.
Attached Files

Alpha N&#11 7;meric LC&#68 ;&#4.bas(1.9 KB, 801 views)

Potrebbero piacerti anche