I would be using the MPLAB 8.89 and CCS C Compiler
Step 1: Go to Project -> Project Wizard
Step 2: Choose the PIC18F1320 microcontroller
Learn Electronics, Microcontrollers, Arduino, BBC Micro:bit, Raspberry Pi, Sensors, Programming and more...
Saturday, 3 September 2016
Using Load cell with the Arduino
A load cell is a force sensing module having a metal structure, with strain gauges mounted in precise locations on the structure. It is easy to use with voltage rating of 5-10V. The force applied to the load cell changes in the output voltage signal directly. Load cells are designed to measure force in one direction. They will often measure force in other directions, but the sensor sensitivity will be different.
Load cells are used in weight, jewellery and kitchen scales. It is usually mounted by bolting down through the screw hole or gluing the end of the load cell where the wires are attached, and applying force on the other end, that is, where the direction of the arrow is. This end is left in floating state.
Load cells are used in weight, jewellery and kitchen scales. It is usually mounted by bolting down through the screw hole or gluing the end of the load cell where the wires are attached, and applying force on the other end, that is, where the direction of the arrow is. This end is left in floating state.
Pseudocode for using push button tactile switches as toggle switch
Normally, a toggle switch is used to turn on or off an output connected to a microcontroller such as LEDs or othe output sensor. What if you have a push button switch and you want to turn off and on an LED without having to keep holding down the switch? In this tutorial, the pseudocode and Arduino code to do such will be provided
The desired input/output behaviour is as follows: The first time the push button switch is pressed the LED should be ON, the second time it is pressed it should be OFF, the third time the switch is pressed, the LED should come ON again, and the fourth time turn off the LED. This on/off pattern should repeat each time the switch is pressed.
The desired input/output behaviour is as follows: The first time the push button switch is pressed the LED should be ON, the second time it is pressed it should be OFF, the third time the switch is pressed, the LED should come ON again, and the fourth time turn off the LED. This on/off pattern should repeat each time the switch is pressed.
MAX7219 LED Dot Matrix and Serial Peripheral Interface
The MAX7219 LED Dot Matrix is an inexpensive kit that contain a MAX7219 and an LED matrix. It’s a simple and inexpensive method of controlling 64 LEDs in either matrix or numeric display form. The MAX7219 is an integrated serial input/output common cathode display driver. It uses a four wire serial interface to connect to microcontrollers. The MAX7219 LED Dot Matrix connects to the Arduino as indicated below:
LED Matrix Arduino
VCC 5V
GND GND
DIN D12
CS D10
CLK D11
The LED Dot Matrix has output and input, more than 1 MAX7219 display is connected in series driven by 1 Arduino. This is done by connecting the Vcc, GND, DOUT, CS and CLK pins from the first MAX7219 to the Vcc, GND, DIN, CS and CLK pins of the second and subsequent MAX7219.
LED Matrix Arduino
VCC 5V
GND GND
DIN D12
CS D10
CLK D11
The LED Dot Matrix has output and input, more than 1 MAX7219 display is connected in series driven by 1 Arduino. This is done by connecting the Vcc, GND, DOUT, CS and CLK pins from the first MAX7219 to the Vcc, GND, DIN, CS and CLK pins of the second and subsequent MAX7219.
Electroluminescence Wire Display
EL (Electroluminescent) wires are composed of a copper core coated with a phosphor layer, a twisted copper wire that wraps around the phosphor layer, an inner and outer PVC plastic sleeve and an AC power source. The phosphor layer is what makes the EL wire light up.
Cheap Home Security Solution using Arduino
The Arduino SD card shield can be used to log data from sensors to be analysed later. In this project, the Arduino Datalogger was used to log readings from a PIR sensor anytime movement is detected. A PIR sensor is used to sense motion of human beings. This setup worked reliably well. It can be used in situations of tracking movements in a room. The code logs in the time (year, month, day, hour, minute, second) when the motion is detected. The SD card can simply be removed and the txt file opened to view the logged data. This is a great home monitoring/security solution, a casing in form of a box can be used to shield the Arduino and logger so it is not noticeable. Here is an excerpt of the Arduino code.
Saturday, 11 April 2015
Why low impedance is ensured during EEG experiments
Electroencephalography (EEG) is the recording of electrical activity along the scalp. It is often required to ensure a low impedance between the scalp and the electrodes. Here is why.
From the figure above,
Rin_amp is the input resistance of the amplifier the EEG electrode is connected to.
Vin is the true voltage of the EEG signal
Reeg is the impedance between the scalp and the electrode
The output voltage, Vout, is the voltage that appears at the input of the amplifier and is given by:
This output voltage is the one that is amplified by the op-amp.
As shown by the equation above, if Rin_amp is far greater than Reeg, Vout goes into the op-amp will be approximately equal to Vin and so there is much confidence that we are amplifying the the input voltage, Vin.
But if otherwise, Vout will be attenuated and will not reflect the input voltage, Vin.
Therefore the input impedance of the amplifier has to be far greater than the input impedance of the EEG signal. Also, it is necessary to keep the input impedance of the EEG signal as low as possible.
From the figure above,
Rin_amp is the input resistance of the amplifier the EEG electrode is connected to.
Vin is the true voltage of the EEG signal
Reeg is the impedance between the scalp and the electrode
The output voltage, Vout, is the voltage that appears at the input of the amplifier and is given by:
This output voltage is the one that is amplified by the op-amp.
As shown by the equation above, if Rin_amp is far greater than Reeg, Vout goes into the op-amp will be approximately equal to Vin and so there is much confidence that we are amplifying the the input voltage, Vin.
But if otherwise, Vout will be attenuated and will not reflect the input voltage, Vin.
Therefore the input impedance of the amplifier has to be far greater than the input impedance of the EEG signal. Also, it is necessary to keep the input impedance of the EEG signal as low as possible.
Op-Amps: Why a high input resistance and low output resistance is required
A very high input resistance is required so that the input becomes an open circuit. A very high input resistance will imply an open circuit. As shown in the diagram below, for an open circuit, the current through Vin will be zero.
From KVL,
-Vs+VRi +Vin=0
-Vs+iRs+Vin=0
Since i = 0,
-Vs+Vin = 0
Therefore, Vs=Vin
If it is an open circuit, the exact source voltage, Vs, gets transferred to the input as Vin. This means that the Ri resistor almost did nothing. Therefore we need a very hight input resistance, Ri, to achieve a zero current, i, so that it becomes an open circuit and all the source voltage will be the input voltage.
This is also true for a voltmeter. A voltmeter should have a very high resistance so that little or no current is able to flow meaning that all the source voltage of the instrument being measured will appear at the input.
A very low output resistance is required so that all the current will be consumed by the load. A very low output resistance is required for an op-amp so that if a load RL is placed in series with it, all the current will be consumed by the load. See the figure below.
From the figure above, this is a short circuit so Vin=0. This implies that all the source current will be eaten up by the load
From KVL,
-Vs+VRi +Vin=0
-Vs+iRs+Vin=0
Since i = 0,
-Vs+Vin = 0
Therefore, Vs=Vin
If it is an open circuit, the exact source voltage, Vs, gets transferred to the input as Vin. This means that the Ri resistor almost did nothing. Therefore we need a very hight input resistance, Ri, to achieve a zero current, i, so that it becomes an open circuit and all the source voltage will be the input voltage.
This is also true for a voltmeter. A voltmeter should have a very high resistance so that little or no current is able to flow meaning that all the source voltage of the instrument being measured will appear at the input.
A very low output resistance is required so that all the current will be consumed by the load. A very low output resistance is required for an op-amp so that if a load RL is placed in series with it, all the current will be consumed by the load. See the figure below.
From the figure above, this is a short circuit so Vin=0. This implies that all the source current will be eaten up by the load
Interrupts in Microcontrollers
Interrupts can be defined as a hardware triggered software event. They are used in microcontroller programming to ensure that events occur in real time.
To implement interrupts, the condition or event is placed inside the Interrupt Service Routine (ISR). Say, when we press a switch we want a response within a specified period, this if statement followed by the corresponding action is placed in the ISR. The ISR is always called at a frequency/period given by the value written into the RELOAD register.
Another use of interrupt is producing a sound at a particular frequency. This is achieved because interrupts are implemented at a given frequency, so the frequency of the interrupt will be the frequency of the sound produced. Other uses are in obtaining sensor readings at every specified time.
In short, interrupts are used whenever we want to produce an output at a particular time irrespective of the line of code or step currently being executed by the microcontroller in the infinite loop. When the hardware event is triggered, the software will round up its current line of execution, then jump to the ISR to execute the codes, after execution, program flow would return to where it left off in the infinite loop.
To implement interrupts, the condition or event is placed inside the Interrupt Service Routine (ISR). Say, when we press a switch we want a response within a specified period, this if statement followed by the corresponding action is placed in the ISR. The ISR is always called at a frequency/period given by the value written into the RELOAD register.
Another use of interrupt is producing a sound at a particular frequency. This is achieved because interrupts are implemented at a given frequency, so the frequency of the interrupt will be the frequency of the sound produced. Other uses are in obtaining sensor readings at every specified time.
In short, interrupts are used whenever we want to produce an output at a particular time irrespective of the line of code or step currently being executed by the microcontroller in the infinite loop. When the hardware event is triggered, the software will round up its current line of execution, then jump to the ISR to execute the codes, after execution, program flow would return to where it left off in the infinite loop.
Subscribe to:
Posts (Atom)










