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 🔗 External reference
This easy-to-construct "Handy Pen Torch" electronic circuit has a low component count and utilizes two power white LEDs for lighting. It operates on a low voltage supply of 4.8V DC.
The Handy Pen Torch circuit is designed to provide a...
Starting today, interesting Arduino projects from various sources will be shared. The author is a novice in this field but is committed to understanding it fully. It should be noted that the projects are not developed by the author,...
The uJDM PIC programmer circuit diagram is designed for programming simple microcontrollers such as the PIC16F84, PIC16F84A, and PIC16C84.
The uJDM PIC programmer is a compact and efficient circuit used for programming a range of Microchip PIC microcontrollers. It operates...
The reader mechanism shown was purchased from All Electronics for $1.50. The unit provides the magnetic head on a spring mechanism along with low level head signal amplifiers and data slicers. Three signal lines coming from the unit provide...
Efforts were made to minimize the number of wire jumpers on this board, but space constraints arose due to the integration of the microcontroller and motor driver on a single board. The design would have been cleaner without the...
To achieve this project, the initial concept involves sampling an input using an Analog-to-Digital Converter (ADC) at consistent time intervals and subsequently displaying the waveform on a graphic LCD. Adjusting the time scale can be done by modifying the...
We use cookies to enhance your experience, analyze traffic, and serve personalized ads.
By clicking "Accept", you agree to our use of cookies.
Learn more