2009 21 Feb

I have been studying PIC 18F67J50 and have order it to make some tests! Since this pic use a very small package TQFP 64 pin (0.5 mm pitch between pins) it is not possible to just connect some thin wires and connected to the breadboard, so I have ordered this demo board but made a small mistake, it is a 0.8 mm pitch, damn:

Wrong board!

Ok, let’s order a proper demo board, this is the result of my first work with TQFP devices using a 0.3 mm tip on the iron (iron? yes, I did it the old way, after all it was my first time! Thanks to my friend dinix to let me use is lab!):

PIC 18F67J50 Prototype board

Not bad for a first time! Now I can actually run some live tests with it! This is also my first time with the super power-full nano watt pics from the 18F family!

2009 04 Feb

This may be useful (manual of the compiler that I use):


2008 02 Feb

I have just acquire this PIC 16F690 due to lack of hardware support from my old PIC 16F628a. Didn’t have I2C Slave by hardware and only 1 PWM (pulse width modulation) module available! I2C Slave by hardware was already tested on my previous post!

I have tested the PWM on this new PIC and found the results to be beyond my expectations! It is also configured with 1 PWM module but with a special capability! This signal will be available in pin RC5/CCP1/P1A and can be multiplexed to 3 other outputs, RC4/C2OUT/P1B, RC3/AN7/P1C and RC2/AN6/P1D. For P1A output the PWM signal will always be present but for P1B, P1C and P1D can be set/reset at any time. In my next example I will configure a PWM pulse with frequency of 500Hz (2ms period) and Duty-Cycle to 25% available to outputs P1A and P1B. From 3 to 3 seconds will switch configuration to activate/deactivate PWM pulse on output P1B.

This will be required to drive my previous module that will control the DC motors (will need to have PWM switching between P1B and P1C - this will invert DC motor direction): http://www.botdream.com/blog/2007/11/01/2nd-h-bridge-circuit-is-now-completed/

For this test I’ve assembled the following circuit:
PWM 2Channels Continue reading »

2008 01 Feb

I have now completed my I2C Master/Slave communication test. Quite happy with the results! Before getting started I needed to refresh my memory on I2C protocol, how Master and Slave devices would communicate, how data flow between devices. Found this nice tutorial on the web: http://www.best-microcontroller-projects.com/i2c-tutorial.html

As I previously referred on other posts, the PIC 16F690 will now support I2C protocol by hardware for the slave device, meaning that Interrupt Service Routine will be available, serving I2C Master whenever necessary without the necessity to pool the I2C bus. This also will permit Slave PIC to run other tasks like acquiring data from Analog-to-Digital inputs, control outputs, read inputs, etc, and still server PIC Slave without causing any delay on I2C bus. Unfortunately I2C Master is not supported by hardware for this PIC (I2C Master mode is also supported, please check datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/41262E.pdf page 197 -> 13.13 Master Mode). Not a problem, Master PIC will receive commands from PC (Via RS232 interface - serial communication) that will be stored on buffer to be processed whenever possible!

For the test I’ve used 2 PICs 16F690 @ 4Mhz and 1 RS232 interface for debug. Master PIC will connect to Lab PC by RS232 (COM1) for debugging purpose and to Slave PIC by I2C bus.

PIC I2C Master/Slave communication

Continue reading »

2008 23 Jan

I have now a new USB In-Circuit Debugger ICD2 that will allow me to program PICs much faster than my old LPT (parallel port) one and debug my PICs hardware by using proprietary Microchip protocol. I have made some test programing my old PIC 16F628A and new 16F690. It works fine! Really fast and have less errors while flashing the PIC. Also, this is now integrated with Microchip MPLAB, just need to activate tool, connect and flash! No more switching between different tools!


Will make real time hardware debug as soon as possible! I’m testing my new PIC 16F690 on I2C communications! Slave device supports I2C Hardware protocol. Master device will need to be implemented by software! Will post results as soon as possible.

2007 28 Nov

Still haven’t completed I2C Master/Slave communication test, but will move on!

I’m now defining how PC will communicate with PIC Master, how will the Robot computer send commands and receive data to the Master PIC. The Master PIC will them make the interface between PC and Sensors/Modules trough an I2C bus.

I have decided to send commands in the following format (PC to PIC Master - frame data):

<id, type, cmd, data0, data1, data2, data3, data4, data5, data6, data7, data8, data9>

id = device ID number (Slave or Master)
type = defines type of sensor/module {10=DCmotor, 11-Servo, …}
cmd = command
data0 to data1 = additional data

The Master PIC will receive the command from Robot computer (Via RS232) and parse it into a special object that will be sent to sensors/modules trough the I2C channel. After sending the commands in the I2C channel, the Master PIC will wait for the acknowledge of that command from the sensor/module. PIC Master will then read data from sensors/modules and save data into special object. When receiving the last byte from sensors/modules, PIC Master will them compose frame data and send it back to Robot computer. Continue reading »

2007 27 Nov

Unfortunately couldn’t test I2C Master/Slave communication between 2 Pic 16F268 due to lack of hardware capabilities! The 16F628 doesn’t have SSP module and so can not support I2C protocol by hardware. I  have tested I2C Master by software when communicating between Pic Master and Dallas DS1721 ‘2-Wire Digital Thermometer and Thermostat’ Slave. It worked fine, but I really need the full capability of I2C Slave by hardware (Interrupt Routine) and at this moment have only emulated the Master side! Also would like to leave my code small and clean! 

I have now found alternative Pic with SPP (I2C by Hardware) support - PIC 16F690 I/P . Still searching for this device on local electronic stores, but no luck yet! Better to order from Internet :) .

While waiting for the new Pics I will try to make some more advanced tests.

2007 20 Nov

This test will be part of one of the main module that I will need to communicate between PC and all sensors/modules. I want for the PC from the robot to communicate with one Master PIC by RS232, exchanging commands and information to/from sensors/modules. Than the Master PIC will make the interface to all sensor/modules by I2C Bus.

Still have a lot of work to do on the H-Bridge module, and the I2C Bus, but decided to test RS232! It was fun to play with and my test worked well!

I’ve just assembled on a test board this simple circuit:

Pic16F628A RS232 Test

Continue reading »

2007 19 Nov

Now that my lab tools are all set I need to test my Pic16F628A to get a PWM signal. This signal will later be applied to the H-Bridge circuit that will control DC motors power. For the test I’ve used this circuit:

Pic16F628A PWM Test Continue reading »

2007 17 Nov

Just made some tests to see how CCSInfo Compiler works! I’m really impressed! Very simple and easy!

For this test I’ve used Microchip PIC 16F628A working with an external 4MHz resonator and 1 led connected to the RB0 (pin6) - also requires one 1KOhm pull-up resistor to the led and the MCLR resistor to VCC.

Led Blink Test

  1. #include <16F628A.h>
  2. #use delay(clock=4000000)
  4. //————————————————————————————————————————————————————————————
  5. void main(void)
  6. {
  7.   delay_ms(100); // power up delay
  9.   setup_comparator(NC_NC_NC_NC);
  10.   setup_vref(FALSE);
  11.   set_tris_b(0b11111110);
  13.   while( TRUE )
  14.   {
  15.     output_low(PIN_B0);
  16.     delay_ms(500);
  17.     output_high(PIN_B0);
  18.     delay_ms(500);
  19.   }
  20. }
  21. //————————————————————————————————————————————————————————————

Continue reading »