Autor Tema: a/d del pic 16f84? como conectar potenciometro  (Leído 7444 veces)

0 Usuarios y 2 Visitantes están viendo este tema.

Desconectado manongo_123

  • PIC10
  • *
  • Mensajes: 25
a/d del pic 16f84? como conectar potenciometro
« en: 15 de Agosto de 2005, 16:57:00 »
hola amigos , esta pregunta que talvez muchos se hallan hecho, pues acabo de ver unos ejemplos de pic basic (yo programo en asembler) que no uso , y vi como en unos de sus proyectos conectaban un potenciometro al puerto a del pic 16f84 para regular velocidad o dimer, quiero saber si eso se puede con ese modelo de pic y si es asi cual seria el codigo en asembler.

Desconectado fenix_jn

  • PIC18
  • ****
  • Mensajes: 418
RE: a/d del pic 16f84? como conectar potenciometro
« Respuesta #1 en: 16 de Agosto de 2005, 00:23:00 »
Ok, en primer lugar el F84 NO posee ADC, creo q t estas refiriendo al 16F88, posee una configuracion identica al F84 + un conversor A/D, revisa bien y veras q no se trata de F84, y si lo es, tendra alguna circuiteria adicional para convertir el valor analogico en valores digitales y pasarlos al PIC

Desconectado xootraoox

  • Colaborador
  • PIC16
  • *****
  • Mensajes: 248
RE: a/d del pic 16f84? como conectar potenciometro
« Respuesta #2 en: 16 de Agosto de 2005, 05:42:00 »
totalmente de acuerdo...... tambien podria ser el 16f628....

quizas tambien puede que este usando una tecnica de un oscilador R/C y no sea precisamente una convercion ADC sino que mide el intervalo de tiempo, si es asi puedo pasarte un ejemplo donde se aplica esa tecnica sobre un secuencial de leds multiplexado de 32 salidas en el cual se regula la velocidad del mismo por medio de un potenciometro usando un f84 y sin ADC


mmmmm.... mejor lo subo ahora ya a algun lado para que quede disponible para el que lo necesite

====================================================================================================================

PIC Controlled 32-LED Knightrider
A PIC processor simplifies the circuit and gives 12 different lighting patterns for the 32 LEDs. You can use it as a rear window break light as an eye catching display.




 
In the early 1980s there was a TV series called KnightRider. Its "star" was a rather clever car going by the fetching name "Kit".


Mind you, Kit was no ordinary car. It had powers and abilities far beyond those of mortal cars. Kit could talk, drive itself and supposedly see using a row of lights on the front which "scanned" from side to side to simulate monitoring what was ahead.


While the KnightRider TV series has long since ceased, such scanning lights have continued appeal and we have published two different KnightRider light displays, one in November 1988 and the other in May 1996. Both of these used 16 LEDs and had a single fixed scanning display pattern.


But both of these were in the days before microcontrollers - or at least before microcontrollers were commonly used in projects.


Our latest version of KnightRider has twice as many LEDs, 32, and a number of different display patterns are available which are selected using a pushbutton switch. There are four scanning sequences, a chaser and a strobe.


If you mounted the display on your car"s parcel shelf, you could also use it as a brake light.


Features
•   32 LEDs
•   12 LED display patterns, including medleys
•   Adjestable pattern speed
•   Adjustable LED brightness
•   12V operation


The patterns

The four scanning patterns include the traditional movement of LEDs from left to right and from right to left which is repeated to simulate scanning across a field in front of the LEDs. Pattern 2 begins with two LEDs in the centre LEDs which then spread (light up) to the left and right and contract back to the centre.



 
Fig.1: in this circuit, the 32 LEDs are arranged in an array, driven in their various patterns by the PIC microcontroller.

Patterns 3 and 4 are similar, with pattern 3 moving from the centre to the outside and then back to centre again. Pattern 4 starts from the outside LEDs and moves to the centre and then back the outside again.


Chaser sequences include a right to left movement and a left to right movement. The strobe patterns can be at a regular or random flashing rate.


For brake light use, there are two patterns. The first lights all LEDs initially for a minimum of about 18 seconds (depending on the speed setting) and then the LEDs randomly switch off until they are all out. Alternatively, you can just have all LEDs lit while ever the brake is applied.


The KnightRider PC board measures 210 x 72mm. All 32 LEDs mount horizontally along one edge of the PC board. There are two trimpots, one to adjust the LED scanning rate and the other to adjust display brightness. A pushbutton selects the display pattern while a LED next to the switch flashes once or more to indicate the pattern that has been selected.


Circuit description

Apart from the 33 LEDs, the KnightRider uses relatively few components and is based around IC1, a PIC16F84 microcontroller. This provides all the LED patterns.


The PIC16F84 has 18 pins, 13 of which can be used as inputs or outputs. For our circuit we are using 12 as outputs to drive the LEDs and one as an input and an output to monitor the pattern select switch and drive the pattern LED. Fig.1 shows the circuit details.


Multiplexed rows and columns




Scope 1: The upper trace is the oscillator waveform at pin 16 (OSC IN). This is a classic sawtooth expected from a relaxation oscillator. The lower trace is the waveform at pin 15 (OSC OUT) which in this RC mode is a square wave at one quarter the oscillation frequency.


While the 32 LEDs are physically arrayed along one side of the PC board, they are actually connected as a matrix of four columns and eight rows, as shown in Fig.1. The eight rows are driven directly from IC1 (RB0-RB7) while the four columns are driven by four transistors, Q1-Q4. These transistors are switched by the RA0, RA1, RA2 and RA3 outputs of IC1.


When the RA0 output (pin 17) is pulled low by IC1, transistor Q1 is switched on and applies power to the anodes of LEDs 1-8. A low output on any of the RB outputs will drive the LED connected to it via its series 150Ùresistor. For example, if RB0 goes low, LED1 will light.


The RA0 line is kept low for a short time before this goes high to switch off Q1. Thus LEDs1-8 are switched off. The RA3 line (pin 2) is then brought low to drive Q2 and the anodes of LEDs 9-16. Now any low RB outputs will then light up LEDs 9-16. Similarly, RA2 (pin 1) is brought low to drive Q3 and LEDs 17 to 24 and then RA1 (pin 18) is pulled low to drive Q4 and LEDs 25-32.


This cycle repeats endlessly with each column of eight LEDs being lit at a very fast rate so that the LEDs appear to be continuously lit rather than only being on for some of the time. This system of driving the LEDs is called "multiplexing". Its big advantage is that it saves power and drastically reduces the number of connections required. If the LEDs were not multi-plexed we would need 33 separate lines (32 actives and one common) whereas with multiplexing we can drive the 32 LEDs using only 12 lines connected in the matrix.


Brightness control

Overall LED brightness is controlled with trimpot VR2. This varies the voltage at pin 3 of IC2 from 5V down to about 2.4V when the wiper is at its lowest point. Op amp IC2 operates as a unity gain buffer amplifier, with transistor Q5 providing extra current drive capability.

 
Scope 2: These traces show the time duration between when power is applied to the circuit and when the LEDs light for the brake light pattern selections. Top waveform is the applied voltage and when this goes high, there is some 67ms before the LEDs light. This is fast enough to display almost instantly the brakes are applied.


If the emitter of Q5 is at 5V, the LEDs will be driven at maximum brightness. Typical LED current will be (5V - 1.8V)/150Ù, or 21mA. This is the pulse current, not average current.


The pattern select switch S1 connects to RA4 of IC1. This pin is normally held at 5V via the 10kÙ pullup resistor. When S1 is pressed, LED33 lights and RA4 is pulled low. This is recognised by IC1 as a switch closure and the next pattern in the sequence of 12 is selected. When the switch is released, IC1 flashes LED33 to indicate the pattern selected. For example, pattern 2 is indicated by two flashes.


Note that the RA4 pin is an open drain output when configured as an output. This allows RA4 to drive LED33 when pin 3 is low. When RA4 is set high, the open drain connection means that it becomes a high impedance output which is pulled high via the 10kÙ resistor. In this condition, IC1 can monitor RA4; if it is pulled low, that indicates that the switch is closed.


No crystal required





   

Fig. 2: here"s the full-size PC board component overlay, with a matching photo to make assembly a breeze!


Most PIC circuits use a crystal for the internal oscillator but this circuit does not require precision timing. For these situations, the PIC can be set up as a relaxation oscillator (similar to the 555) whereby a capacitor connected to pin 16 is charged from the positive supply (+5V) via a resistance and then discharged via an internal transistor.


In this case we connected a 15pF capacitor to pin 16, charged from +5V via trimpot VR1 and a 4.7kÙ resistor. The classic sawtooth waveform of the oscillator can be seen in the top trace of Scope 1.


Interestingly, the waveform at pin 15, OSC OUT, is not the same as at pin 16. Instead it is a square wave at one quarter the frequency.


Frequency of operation can be varied from about 4MHz when VR1 is set to minimum resistance, down to about 500kHz when VR1 is at maximum resistance.


Transistor Q6 and its associated resistors provide a reset for IC1 when the supply is below a certain voltage. This ensures correct start up for IC1 when power is applied.


The circuit can be powered from a 12V battery, DC power supply or DC plugpack. Diode D1 gives reverse polarity protection while the 10Ù resistor and zener diode ZD1 provide transient protection.


The 12V supply is filtered with a 100ìF capacitor before being applied to REG1, a 5V regulator. Its output is decoupled with a 10ìF capacitor to ensure stability.


Software


The software required to provide the various LED display patterns was written to minimise the number of instruction codes. This is because there are only 1024 bytes of memory and we would quickly run out of space if we were to list each individual LED and its state during a pattern sequence. This normal approach involves using a lookup table.


Instead of using a lookup table, the software makes note of the fact that much of the sequence is repetitive and only a short list of LED switching operations is required. This list is used in various ways to generate the required pattern.


The efficiency of this approach is evident by the fact that we managed to include some 12 distinct patterns into the software with some space left over. In contrast, if we had used a lookup table it would have only allowed one or maybe two patterns at the most.


The full software listing for the KnightRider is called knight.asm;


Construction




 
Full-size PC board artwork. Use this to check commercial boards or to make your own board.


The KnightRider is constructed on a PC board coded 08105021 and measuring 210 x 72mm. Begin construction by checking the PC board for shorted tracks or any breaks in the copper pattern. Check the pattern against the published artwork to verify that it is correct. Repair any defects on the PC board before starting assembly.


Fig.2 shows the component overlay for the PC board.


First, install all the links on the PC board. Then install the resistors, using the colour codes shown in the parts list as a guide to selecting the values. You can also check each value with a digital multimeter to be sure that you have the correct resistor for each position. The diodes can be installed next, taking care not to confuse zener diode ZD1 with standard diode D1.


IC1 is mounted using a socket while IC2 can be soldered directly into the PC board. The 3-terminal regulator is mounted horizontally, so carefully bend the regulator leads before inserting them into the relevant holes on the PC board. It is mounted onto a small heatsink and secured with an M3 screw and nut.


When installing the five transistors, make sure that the BC338 is placed in the Q5 position.


Next, install the capacitors. The codes of low value types are listed in the parts list. The electrolytic capacitors will have their values marked in mF; be sure to orient them correctly.


Switch S1 should be installed with the "flat" side oriented as shown Fig.2. Insert LED 33 with the anode (longer lead) placed toward the VR1 side of the PC board. Trimpots VR1 and VR2 and the PC-mount terminal block can then be soldered into place.


Finally, the 32 LEDs can be installed along the edge of the board. They are placed with the anode leads (longer lead) to the left.


You can preform all the LED leads by cutting a length of cardboard 10mm wide. Place the LED across this with the anode to the left and bend the leads downward. This will allow the LEDs to be inserted into the PC board with sufficient clearance for the LED body to just protrude over the front edge of the PC board.


Check your work carefully for correct orientation of the capacitors, for the correct transistors in each place and the correct orientation of IC2 and the socket for IC1. Do not install IC1 yet.


Testing


Now apply power to the +12V and 0V supply terminals and measure the voltage between the metal tab of REG1 and pin 14 of the IC1 socket. This should be +5V. If this is correct, disconnect power and insert IC1, making sure it is oriented correctly.


Apply power again and check that the LEDs start to light up and produce a chasing pattern. The initial pattern is the KnightRider chaser (Pattern 1) with the LEDs moving from left to right and from right to left.


Check that you can adjust the speed with trimpot VR1 and vary brightness with VR2.


You can test for the other patterns by pressing the pattern switch. Each time you press the pattern switch, LED33 will flash the required number of times and then the selected pattern sequence will start to run.


You may need to adjust the speed trimpot (VR1) so that you can easily count the number of flashes from LED33.


Table 1 shows the 14 patterns available.
Table 1: Patterns Available
No.    Type   Pattern Description   Repeat
1   Scan    LEDs move from left to right and then right to left   yes
2   Scan   LEDs move symmetrically from centre to outside    yes
        and from outside to centre   
3   Scan   LEDs move symetrically from centre to outside   yes
           
4   Scan   LEDs move symetrically from outside to centre   yes
5   Scan   Patterns 1, 2, 3 & 4 selected in sequence   yes#
        with change every power up   
6   Medley   8 cycles of pattern 1   yes ##
        16 cycles of pattern 2   
        16 cycles of pattern 3   
        16 cycles of pattern 4   
7   Chaser   LEDs chase from right to left   yes
8   Chaser   LEDs chase from left to right   yes
9   Strobe   All LEDs on then off at regular rate   yes
10   Strobe   All LEDs on then off at random rate   
11   Random    LEDs lit at random until all on,   yes
        then off at random until all off   
12   Medley   100 cycles of pattern 7   yes+
        100 cycles of pattern 8   
        20 cycles of pattern 9   
        20 cycles of pattern 10   
        2 cycles of pattern 11   
13   Brake   All LEDs on at power-up for 18s minimum   no
        then off at random until all off   
           
14   Brake   All LEDs on at power up and remain on until   no++
        power off   
# (of selected pattern)
## (Medley repeats of patterns 1, 2, 3 & 4)
+ (Medley repeats of patterns 7, 8, 9 & 10)
++ (only lights again after power off and on again)



Parts List - KnightRider
1 PC board coded 08105021, 210 x 72mm
1 heatsink, 19 x 19 x 10mm
1 2-way PC-mount screw terminal
1 snap-action PC pushbutton switch (S1)
1 M3 x 6mm screw and nut
4 adhesive rubber feet
1 350mm length of 0.8mm tinned copper wire

Semiconductors

1 PIC16F84P (IC1) programmed with Knight.hex
1 LM358 dual op amp (IC2)
1 7805 regulator (REG1)
5 BC328 PNP transistors (Q1-Q4, Q6)
1 BC338 NPN transistor (Q5)
1 16V 1W zener diode (ZD1)
1 1N4002 diode (D1)
33 5mm red high-brightness LEDs (LED1-LED33)

Capacitors
 
1 100ìF 16VW PC electrolytic
5 10ìF 16VW PC electrolytic
1 0.1ìF MKT polyester (code 100n or 104)
1 15pF NP0 ceramic (code 15p or 15)

Resistors (0.25W, 1%)

1 68kÙ
1 47kÙ
1 22kÙ
2 10kÙ
1 4.7kÙ
2 1kÙ
4 680Ù
8 150Ù
1 10Ù
2 50kÙ horizontal trimpots (code 503) (VR1,VR2)




Bueno y el codigo fuente


aqui   ASM
aqui    HEX


bueno espero sea de utlilidad

Desconectado RaDoN

  • Moderadores
  • PIC24H
  • *****
  • Mensajes: 1498
RE: a/d del pic 16f84? como conectar potenciometro
« Respuesta #3 en: 16 de Agosto de 2005, 06:06:00 »
Joder, para un proyecto tan sencillo que forma de complicarse ... pongo un display tb multiplexado y le marco el tiempo digitalmente o uno con ADC y no te comes la cabeza con el soft, que total, el pic te va costar 1 € mas ...
Si juegas contra el mejor, pierdes como los demás.

Desconectado sureshmatugama

  • PIC10
  • *
  • Mensajes: 1
Re: RE: a/d del pic 16f84? como conectar potenciometro
« Respuesta #4 en: 09 de Mayo de 2011, 06:17:09 »
iam suresh
i wont this projects
i cant dowanload it
place email me
sureshmatugama@yahoo.com
thank
skype sureshmatugama


 

anything