Sophomore Clinic II, Spring 2007

Navigation on this page

v     Instructions on Building and Integrating your PIC Board, H-Bridge, and Electromagnet Drive

v     Presentations

Ø      Building your Microcontroller

Ø      PIC Programming in C

Ø      Integrating the PIC with the H-Bridge (this one is key; now updated to show MOSFET pinout)

v     PIC C Code for 16F876A in the Crane Project

Ø      Pushbutton toggles with key bounce logic

Ø      Push to hold logic (New April 18)

v     Manuals

Ø      The CCS PIC C Compiler Manual – a free PDF file for download from the Microchip web site!

Ø      Introduction to PIC C – about $30.00 from Microchip.  Dr. Beard has a copy if you want to see one.

v     Instructions for setting up workstations in Rowan Hall room 237 to program your PIC project board

 

Back to Main Page

Instructions on Building and Integrating your PIC Board, H-Bridge, and Electromagnet Drive

Please begin with main01.c or main02.c for your project and modify it to suit the way you decided to build your interface.  Note that the demo we ran used main01.c, and that main02.c has examples for push-and-hold pushbuttons.

 

You are hooking together all these things:

v     Pushbuttons and thumbwheels, either the interface for your project or a breadboard,

v     The PIC project board,

v     The two CMOS chips,

v     The H bridge

v     The electromagnet drive, and

v     The electromagnet.

 

The process of debugging everything and getting it working is something I've shown several teams.  It goes like this:

  1. Decide exactly what you want your interface buttons and thumbwheels to do.
  2. Pick one of the posted programs and modify it to suit your interface design.  Make sure that you are clear with the pins on the PIC that are used for input and for output.  More on the PIC below.
  3. With the interface connected but the CMOS chips not plugged in, and no power to the magnet MOSFET, step through your program and make sure that its logic is operating properly.  Fix the program as required to make sure that its outputs are what you want and expect.
  4. Plug in the CMOS chips and make sure that the outputs are what you need to drive the H-bridge, and that the drive changes according to what you are doing with the interface (forward, backward, up, down).  Check the magnet drive and make sure that it is doing what you expect.
  5. Plug in the H-bridge and see if it will run the motors.  Hook up the electromagnet, powered from the bench supply like the H-bridge, and verify that it works.

At each stage, you may need to fix or change a couple of things.  The point is that you are working through the system, point by point, getting things working from the input to the output.

 

Run the PIC in the debug mode while a watch window for local variables is open.  You can check the bits that are being put out on the pins of the PIC by looking at the values of the local variables in the watch window as you step through the program.  You can also check them on the PIC board with a voltmeter or oscilloscope.  There are some input and output pins on the PIC that can't or shouldn't be changed:

 

v     The A bus pins are analog input pins.  Use A0 for the forward-backward thumbwheel input and use A1 for the up-down thumbwheel.  If you omit one or both of these thumbwheels from the interface, put it on the PIC board so that you can control the motor speeds as a setup adjustment.

v     The PWM outputs are on pins C1 for the up-down and C2 for the forward-back; this is hard-wired within the PIC and can't be changed.  The up-down toggle signal is on pin C0 and the forward-back toggle signal is on pin C3, and our wiring examples on the presentation "Integrating..." show the use of these pins.  I believe that the magnet drive output is on pin C4.

v     In my sample programs, I used the B bus pins for pushbuttons.

 

Make sure that the notches on the chips (the end with pins 1 and 14) are pointing away from the eight-connector jack to the H-bridge, and that you have power on pin 14 and ground on pin 7 of both CMOS chips.  On the CD4069 hex inverter, the chip nearest the eight-pin connector, you should see these signals with an oscilloscope:

v     Pins 3 & 4 should be the complement of each other, and pin 3 should drive a P channel MOSFET (off is high) and pin 4 should drive an N channel MOSFET (off is low).  Likewise pins 5 & 6.  When you toggle forward-back, the PWM should switch back and forth from 3 & 4 and 5 & 6.  Likewise, 11 & 10 and 9 & 8 are the equivalent pins driving the up-down motor.

v     The hookup of the CMOS inverter to the eight-connector jack for the H-bridge control is critical.  You can use the picture on slide 13 to make sure that the connections are right.

v     When you plug in the H-bridge to the PIC board, make sure that you aren't one pin off one way or the other.

 

Back to top of page

Presentations

Building your Microcontroller

Click here for a PDF file.  Press F7 to look at it in Acrobat full-screen mode, similar to PowerPoint’s Slide Show mode.

PIC Programming in C

Click here for the presentation given on April 2 (188 K PowerPoint file).

Integrating the PIC with the H-Bridge

Click here for the presentation given on April 9 (1.8 MB PowerPoint file) including chip pin outs, wiring diagram, and photos.  Updated April 26.

 

Back to top of page

PIC C Code for 16F876A in the Crane Project

You can use one of these programs as a starting point in the code for the PIC 16F876A for your project.

Pushbutton toggles with key bounce logic

Click here to download version 01 of quick start baseline PIC software.  This version uses pushbuttons to toggle propulsion, lift, and magnet on-off, with key bounce logic.  File name is main01.c

Push to hold logic

Click here to download version 02 of quick start baseline PIC software.  This version uses push-and-hold logic; two pushbuttons are used for propulsion, one for forward and one for back, and two pushbuttons are used for lift and lower.  A single pushbutton is used with push-and-hold for magnet actuation.  File name is main02.c

 

Back to top of page

Manuals

The CCS PIC C Compiler Manual

Click here to download the CCS PIC C compiler manual as a PDF file from the CCS web site.  CCS sold us multiple licenses but gave us only one paper manual.  But, you can browse the PDF file on your own machine for free.

Introduction to PIC C

Click here for the CCS web site page where you can purchase Introduction to PIC C by Nigel Gardner for $29.95 plus shipping.

 

Back to top of page

Instructions for setting up workstations in Rowan Hall room 237 to program your PIC project board

Click here to see step-by-step instructions on bringing up your in-circuit debugger and programmer for your PIC project board.  NOTE:  We will have a workstation dedicated to PIC programming in Rowan Hall 237 on April 19.

 

Back to top of page