Description: Communication with the MCP3028 ADC chip is achieved through a straightforward serial interface that adheres to the SPI protocol. The PIC16F84 or PIC16F628 does not possess a hardware SPI peripheral. However, a software-implemented SPI protocol can facilitate communication with the 12-bit MCP3028 ADC device. An example of this communication is illustrated in the accompanying circuit diagram. The ADC results are displayed on an LCD in hexadecimal format (converted from binary code). A push button (pin 6, RB0/INT) is used to select the ADC channel (which ranges from CH0 to CH7). By connecting a potentiometer to the selected channel and adjusting it, the hexadecimal value will change accordingly. The SPI communication protocol requires four lines for interfacing. Utilizing a software-implemented SPI protocol allows for communication with multiple ADC devices. The circuit diagram remains the same as that for the 12-bit ADC interfacing, with the only difference being the source code, which changes the binary code to ASCII code with decimal numbers. This requires certain mathematical functions, such as division and floating-point operations. Assembly code for these mathematical functions can be found on the Microchip website, or alternative C compilers such as Piclite for PIC16F8X/C8X series, CC5X C, and Pacific C can be used. The provided hex files utilize the Microchip Math Library (in assembly code) for this simple multi-channel digital voltmeter device (using 16 bits for calculations). The maximum hexadecimal value for the ADC channel is FFF, which corresponds to a decimal number of 4095. This will be displayed on the LCD as 5.11 volts. Hex files for PIC16F84 and PIC16F628 can be downloaded as F84dec.zip and 628dec.zip, respectively. When using PORTA pins for interfacing I/O, it is necessary to define/set the I/O function for PIC16F628. The initial PORTA settings for I/O functions are as follows: `clrf PORTA`, `movlw 0x07` (to turn comparators off), and `movwf CMCON` (to enable pins for I/O functions). It is important to ensure that these settings are performed in Bank 0. This setup is particularly critical when migrating source code from the PIC16F8X series to the PIC16F62X series. Always consult the data memory map in the PIC datasheet to ensure that the general-purpose registers used are within the appropriate range when transitioning between different types of MCUs. For example, the general-purpose register for PIC16F84 ranges from 0x00C to 0x04F (in Bank 0), while for PIC16F628, it ranges from 0x020 to 0x07F (in Bank 0), 0x0A0 to 0x0EF (in Bank 1), and 0x120 to 0x14F (in Bank 2). It is advisable to define addresses in sequential order; if they are out of range, they can be redefined easily. When using bit 4 (RB4) of PORT B of the PIC16F62X series as an output pin, ensure that the MCU is not programmed in low-voltage programming mode (refer to the Microchip datasheet), as this will configure it as a Schmitt Trigger input, independent of the TRISB register I/O direction setting. The opto-isolator is crucial to prevent damage to the MCU from feedback voltage from the power transistor. Two adjustable voltage regulators are implemented to set the running voltage and stopping/holding voltage for the stepper motor. The running voltage is activated by the step pulse input, which also signals motor rotation. A simple source code utilizing an interrupt method to alter the step sequence (one wave) can be downloaded as F628_stepper for PIC16F628. A straightforward mathematical algorithm can drive more complex step sequences, such as half-step sequences, including half-step 5-phase steppers. Another stepper motor circuit for an X-Y table project is available. The numerical LED display module is commonly used in display applications. The most prevalent numerical LED display modules consist of either 8-segment or 16-segment LED units. However, these display modules are limited to showing numerical characters (0 to 9) and a few alphabetical characters. Most alphabetic messages are displayed using alphanumeric LED modules arranged in a dot matrix. The 24-segment LED display module is designed to display both alphabetic (A to Z) and numerical (0 to 9) characters.Communication with the MCP3028 ADC chip is done using a simple serial interface compatible with the SPI protocol. The Pic16f84 or Pic16f628 didn`t had hardware SPI peripheral. However, software implemeted SPI protocol can be done to communicate with 12 bit MCP3028 ADC device. The example of this communication shown as following circuit diagram. Th e ADC result shown on LCD with hex value (conversion from binary code). Press the push button (pin 6, RB0/INT) to select the ADC channel (8 channel from CH0 to CH7). Then, connect the potention meter to the channel and turn it. You will see the hex value change accordingly. The SPI communication protocol need 4 line for interfacing. Using software implemeted SPI protocol enable communication with more than one ADC device. The circuit diagram same as above 12 bit ADC interfacing. The only different is the source code which the binary code has been change to ASCII code with decimen number. This need some math fuction such as divide function and floating point. The math fuction for assembler code can find from Microchip Website. You can also find some documen of math fuction from or use C compiler such as Piclite for PIC16f8X/c8x series, cc5x c, pacific c and so on.
The following hex file are use Microchip Math Library (assembler code) for this simple multi channel digital voltmeter device (using 16 bit for calculation). The maximum hex value for the ADC channel is FFF equal to decimel number 4095. This will display on the LCD as 5. 11 volt. Download hex file for Pic16F84 here: F84dec. zip. Download hex file for Pic16F628 here: 628dec. zip. If using PORTA pins as interfacing I/O, you need to define/set the I/O fuction for PIC16f628. Generally, the initial PORTA setting as following for I/O fuction: clrf PORTA movlw 0x07 ;turn comparators off and movwf CMCON ;enable pins for I/O functions Note: Ensure the above setting done at Bank 0.
The above setting especially important if you want to migrate the source code from Pic16f8X series to Pic16f62X series. Always refer to data memory MAP (on Pic datasheet) to ensure that the general purpose register used not out of range when migrate one type of MCU to another type of MCU.
As example, general purpose register for Pic16f84 was 0x00c to 0x04f (at bank 0). For Pic16f628 was 0x020 to 0x07f (at bank 0), 0x0a0 to 0x0ef (at bank 1) and 0x120 to 0x14f (at bank 2). It is better to define the address follow sequence. If out of range, you can re-define it easly. When Using bit 4 (RB4) of PORT B of Pic16F62X series as a output pin, ensure that the MCU not programmed at low voltage program mode (see Microchip datsheet) if not it will set as Schmitt Trigger input and independence of TRISB regeister I/O direction setting.
The opto-isolator are important which prevent destroy of MCU by the feeback voltage from power transistor. Two adjust-able voltage regulator used to adjust the running voltage and stopping/holding voltage of the stepper motor.
The running voltage on by the step pulse input which also signal to rotate the motor. The simple source code using interrupt method to change the step sequence (one wave) download here: F628_stepper for Pic16F628. Simple mathematics algorithm able to drive more complicate step sequence (such as half step) even for half_step 5phase stepper.
Another stepper motor circuit for X-Y table project click here: X-Y table project The numerical LED display module was widely used in display application. The most common numerical LED display module consists of either 8 segmented or 16 segmented LED units.
However, this type of display module only limited to display numerical character (0 to 9) and a few type of alphabet character. Most of alphabet word message displayed using alphanumerical LED modules with dot matrix arrangement.
The 24 segments LED display module designed in such a way that enable it to display alphabet (A to Z) and numerical (0 to 9) character. Th
A conversion technique known as half-flash combines the speed advantages of flash conversion with the circuitry efficiency of successive approximation. In an 8-bit half-flash converter, two 4-bit flash converter sections are integrated. The upper flash converter compares the input signal...
The ADC 207 is the first analog-to-digital converter to utilize Flash Converting technology based on an advanced high-speed VLSI 1.2-micron CMOS process. This innovative process enhances the unique capabilities of the ADC 207, providing excellent speed, good linearity, and stable...
Almost any 2x16 character LCD module with Hitachi HD44780 controller chip will work. The LCD pin numbers on the schematic are not valid for all LCD modules. Please check the actual signal names on your particular LCD module. The selected...
The image below displays the schematic diagram of the SPI Flash programmer hardware interface. Power for the interface can be supplied using either a 9V DC adapter or a 9V battery. The 74HCT367 integrated circuit (IC) buffers the adjacent port...
To get enough outputs from the PIC chip, a pair of 74HC164 shift registers was used. These need only two lines from the PIC (data & shift) to produce the twelve signal pulses for the servos. A single bit is...
Normally, an analog-to-digital converter (ADC) requires interfacing with a microprocessor to convert analog data into digital format. This involves additional hardware and software, leading to increased complexity and overall cost. The circuit of the A-to-D converter presented here is based...
This high power led mood light is based on PIC16F628 and the ability of this mcu to produce PWM pulses. Varying pulse width we can produce millions of color combinations using only the three basic colors. So only one RGB...
This clock timer utilizes a PIC16F628 microcontroller to display a 3.5-digit time format and control an external load. It is programmable to time intervals from 1 to 59 minutes. The clock features a calendar that accounts for leap years and...
Flash-back to the 60's with this 5 channel unit with up to 100 watts per channel. This unit uses a PIC16F84 with an 8 bit A/D. The signal from both stereo channels is combined and digitized. Each of 5 frequency...
We use cookies to enhance your experience, analyze traffic, and (if you allow) serve personalized ads.
By clicking Accept All, you agree to our use of cookies.
Learn more