Originally Posted by Chris31
I'm gonna pay close attention to this one....do you gove out magic jelly beans too?
Component values can eventually magically get calculated and posted here. Even codes magically debugs itself.Originally Posted by Curiosity
That's also in Microsoft Visual Studio .NET 2010. While you're working, it searches the world for anyone else doing the same thing and steals their code for you.Originally Posted by Chris31
I am going to post this here. I understand how the PIC ADC checks voltage, but how do I use it to check current?
Lets say I want to read out how much current is being used by the system.. How do I tell the PIC what the max is?
you need a shunt. google away
parallel resistance is the way to go. But you need to have an initial calculation of how much current you can really allow in a given loop. This is done simply using Ohm's law ( V = IR). If the current is reasonably small , you can just feed it thru a hi-Z circuit ( ie Op Amp) and derive the analog output from there to feed to your PIC ADC. Also for easy PICking, I would like to suggest learning Pascal instead of C. mikroElectronika offers their mikroPascal compiler and a very good IDE similar to Delphi - for FREE ( if you are compiling up to 2K of code) At a bigger program development, you have to pay for the software. The compiler is doing a real good code optimization. I have designed a 3-in one clock/darkroom timer/alarm clock using PIC16F628A and the resulting code was just 1.5K. A good treat from the mikroE guys. .
In putting together my car PC I wanted to have inputs from battery, temperature, charge / discharge Amp meter for battery as well as the doors, lights and handbrake. There have been a few designs done but none did all I wanted. So I designed a small PCB (3.5 x 2.8 inches) to do all the functions and included robust protection on everything. The circuits are attached and will give you one example of how to measure bidirectional current flow current flow.
There are inputs for :
Internal Temperature both using DS1821 digital thermometer in a small transistor size case
Voltage Input 1 main battery
Voltage Input 2 aux battery
Voltage Input 3 spare
The three voltage inputs will read up to 25 volts with .1 volt resolution.
Current Interface to hall effect sensor for Amp meter to measure battery charge / discharge current. The current sensor is a Honeywell CSLA2DGI which fits over the battery hot cable and will measure +/- 150 Amps. Magnetoresistive types can also be used.
Front Door Left 14 digital inputs with 12 volt interface
Front door right
Rear Door Left
Rear Door Right
The interface is serial RS232 so can easily be converted to USB for a few dollars. The Analogue section can be powered down reducing the current consumption allowing the unit to remain powered and detect doors opening and starting the DC power supply for the PC. The serial interface sends the voltages and current every second, the temperature every five seconds. When a digital input changes state the signal is debounced then transmitted along with the new state. The PC can request the state of all inputs to sync at boot time.
All inputs and outputs are protected against shorting to 12 volt rail or ground.
The microcontroller used is a NXP 89LPC933 which is compatible with 8051 code. It can be programmed in circuit over the serial interface.
the doors, indicators, reverse etc, what are those?
do they tell the RS232 that a door is ajar, or if reverse light is on?
can you describe more on how you did the measurements of the current?
I use the circuit board to input all the signals mentioned to the carPC over the RS232 link (actually uses a serial to USB converter). The idea for the doors, bonnet and boot was to use as part of a security system. If any of these were opened then the PC would startup and do something… have yet to work on this. In normal use I start the PC when any of the doors open, it gains a bit of time in getting the PC booted. I use the reversing light input to change to a screen showing the rear camera which is over USB2 and the reversing distance system ( Circuit for Ultrasonic (Parking) Sensor ) readouts.
I will use the handbrake to prevent the video and DVD players from working at some point.
Lights on is used to dim the back light of the LCD and the cabin light is used to bring back up to full brightness at night when interior light is put on.
I plan to do a audible warning when the indicators are left on longer than they should, when I forget them and the music is a bit loud and cannot hear them click.
The other signals I do not currently use.
To measure current there are two main ways of doing it, one is to have a low value resistor than will develop a voltage across it as the current increases according to Ohm’s Law. Volts = Amps x Rvalue . To do this means inserting a heavy duty resistor in one cable of the battery and measuring the voltage across it. To keep losses small the resistor must be very small which means the voltage is small. The voltage needs to be amplified to get a range that can be fed to the AtoD. The direction of current flow determines the polarity of the voltage.
The other main method is to use the magnetic field that is produced when a current flows. Special transducers are available to measure Ac and Dc current. DC transducers are more expensive. A typical Hall effect transducer will output a voltage at no current and then either positive or negative depending on direction of current flow.
To interface the Hall effect that I have used. When no current is flowing the output is half supply (4V). The preset allows the calibration of this value. The output will then move either side of 4V as current flows. The two opamps then scale this and drop it so that it is centred on the 3V3 rail and maximum current takes it to 3V3 or ground, an AtoD output of 00 or ff (hex)
In both cases I need to scale this voltage and translate it to the 0 to 3V3 power supply of the micro. By using the AtoD so that zero current gives the code of half scale 1000 0000 (in binary) I can measure +127 units and -128 units. I have this roughly calibrated to in Amps. I convert the value to a two’s complement format before send to PC.
My Dear friends,
I'm need some help on PIC16F877A have a comparator's voltage reference module.
Do anyone know on pg 141 of the data sheet PIC16F877A on the bits 5 why we need to devide by 24 step size or devide by 32 step size ???
what is step size ???
at below I had the picture on that page.