|
|
View previous topic :: View next topic |
Author |
Message |
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Thu Sep 18, 2014 5:15 am |
|
|
man, I'll do anything to NOT shovel 10 cuyds(1/2 dump truck) of gravel !!
0x27 and 0x37 are the data to allow the PIC to display '000' on the LEDs IF wired with transistors, that just happen to be missing, so in this case, it will NOT work as the original programmer designed the hardware.
There were probably some 2N2907s(PNP,generic) and resistors driving the CA displays.....'missing' in the schematic about 5 posts ago.
hth
jay |
|
|
gpsmikey
Joined: 16 Nov 2010 Posts: 588 Location: Kirkland, WA
|
|
Posted: Thu Sep 18, 2014 7:44 am |
|
|
Could be worse - with gravel, you get tired, you take a break, have a cold one then get back to work. Now, if it was concrete, you just have to move faster and KEEP MOVING !!!
mikey _________________ mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3 |
|
|
sahu77
Joined: 08 Sep 2011 Posts: 202
|
|
Posted: Mon Oct 13, 2014 11:13 am |
|
|
Mike Walne wrote: | sahu77 wrote: | any body can explain this line ?
TRISA=0b00010000;
PORTA=0x27;
TRISC=0b00000000;
PORTC=0x37; |
Oh, come on Sahu.
The lines are very close to your own thread dating back to February this year.
Like I said before, you can work out with pencil and paper what the effects are.
(Assuming you know whether the displays are CA or CC.)
Mike |
yes sir I want deals this code with 1CA+2CC displays.
pl help me how off all display (1CA+2CC) ? _________________ sahu |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Mon Oct 13, 2014 12:28 pm |
|
|
Pretty hard to even think about this considering I can buy a 7 function DVM for $3 but , I do like a challenge.
I'd use the CA LED as the 100s digit, the CC LEDs as 10s and units.
A) Create code to count from 00 to 99 on the CC LEDs.
B) Create code to count from 0 to 9 on the CA LED.
C) Then 'merge' the two code fragments into a 3rd program counting from 000 to 999.
The 'trick' is to use 2 different lookup tables for the segment addressing and to test 'when 100s digit is needed use CA table else use CC table.
It's not that hard ONCE you've got a 'plan of attack'. Break the project into those 3 sections and it should work as simple as A-B-C.
hth
jay |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
Re: Voltmeter with 7-segment display |
Posted: Mon Oct 13, 2014 8:22 pm |
|
|
abadade wrote: | hello,
I want to make a digital voltmeter based on the PIC16F676 and 3 digit max, 30v with a lower consumption of 15 mA. I already tested it but consumption was 30 mA.
Thank you |
You are wasting a lot of power in the current limiting resistors for the LEDs. The LEDs themselves have a forward voltage (voltage across the LED when on) of between 1.8 and 2.2 volts with a typical forward voltage of 2.0 volts. Lets say hypothetically you have an average of 25mA being consumed by the LED display.
Your circuit has a series resistor between the collector and the LED anode. Strictly speaking this is not required as the current per LED segment is limited by the segment resistor a-g and dp. Without the collector resistor all segments of all displays when on will be the same intensity as all other segments that are on (what you would expect). The additional collector to LED-anode resistor has the effect of limiting the current when more than one segment of a LED is illuminated (possible an attempt to limit a digit with a lot of segments illuminated, such as 8, appearing too bright when next to a display showing a one digit.
So for the sake of the rest of this description, I will ignore the collector resistor but you can naturally use it once you understand what is going on. So.... with an average current of 25mA, the total power consumption of the display is 5v x 25mA = 125mW. The power dissipated by the LED is 2v x 25mA = 50mW. In other words, more power is being dissipated by the segment resistors (75mW) than by the display.
How to improve this?
Run the entire circuit from 2.5 volts. Use a switching regulator (not a linear regulator) to drop the 5 volts to 2.5 volts. The segment resistors would now have to drop 0.5 volts instead of three volts so the power wasted is significantly less. The resistors will need to be reduced in value by the ration 3v/0.5v to ensure the current limit value will be the same and therefore the LED intensity per segment will be the same.
In this scenario the total power consumption for the LED section will be 2.5V * 25mA = 62.5mW. Assuming the switching regulator has an efficiency of 90%, the total power consumption for the LED section will be 69.4mW. The effective current from the 5 volt rail (LED driver section) = 69.4mW/5v = 13.9mA
I have ignored the current consumption of the PIC and power dissipation of the base bias resistors for the transistors however similar savings will be achieved for these components. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
sahu77
Joined: 08 Sep 2011 Posts: 202
|
Re: voltmetre numerique a 7 seg |
Posted: Fri Dec 26, 2014 4:04 pm |
|
|
abadade wrote: | Code: |
#include <16F676.h>
#device adc=10
#fuses INTRC_IO,NOWDT,PUT,NOPROTECT,BROWNOUT,NOMCLR
#use delay (clock=4000000) // 4MHz clock
#rom 0x3ff={0x3444}
#byte PORTA = 0x05
#byte PORTC = 0x07
#byte TRISA = 0x85
#byte TRISC = 0x87
#define SPORTA PORTA
#define SPORTC PORTC
#define TICKS_BETWEEN_INTERRUPTS 1500 //5000
#define INTERRUPT_OVERHEAD 35
#define TMR1RESET (0xFFFF-(TICKS_BETWEEN_INTERRUPTS-INTERRUPT_OVERHEAD))
const char SegCode[11] = {0x40,0x57,0x22,0x06,0x15,0x0C,0x08,0x56,0x00,0x04,0xFF};
// 0 1 2 3 4 5 6 7 8 9
const char Seg_mask_C[7] = {0x01,0x02,0x4,0x08,0x10,0x20,0x00};
// C0 C1 C2 C3 C4 C5
const char Column[3] = {0x02,0x01,0x04};
static char Segment[3] = {0x7f,0x7f,0x7f};
static char Segment_port[2] = {0x7f,0x7f};
static unsigned char ColCount=0x00;
static unsigned char SegCount=0x00;
void CPU_SETUP(void);
void Display(void);
void HTO7S(unsigned int32 Num);
byte i;
unsigned int32 result;
#INT_TIMER1
void Timer1(void)
{
set_timer1(TMR1RESET);
Display();
}
void main()
{
unsigned char i;
CPU_SETUP();
while(true)
{
result=0;
for (i=0;i<20;i++)
{
set_adc_channel(3);
delay_ms(1);
result=result+read_adc();
}
//result = 0x3fe;
HTO7S(result/20);
delay_ms(1000);
}
}
void CPU_SETUP()
{
setup_comparator(NC_NC_NC_NC); // not use comparator module
setup_adc_ports( sAN3 | VSS_VDD);
setup_adc(ADC_CLOCK_DIV_64);
TRISA=0b00010000;
PORTA=0x27;
TRISC=0b00000000;
PORTC=0x37;
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
set_timer1(TMR1RESET);
enable_interrupts(GLOBAL);
enable_interrupts(INT_TIMER1);
}
//-------------------------------------
// Display routine
//-------------------------------------
void Display()
{
if (ColCount>=3) {ColCount=0;SegCount++;}
if (SegCount>=7)SegCount=0;
Segment_port[1] = Segment[ColCount] | (Seg_mask_C[segcount]^0xFF);
if (segcount>=6)Segment_port[0] = ((Segment[ColCount]>>1) & 0b00100000) | (Column[ColCount]& 0b00000111);
if (segcount<6)Segment_port[0] = 0b00100000|(Column[ColCount]& 0b00000111);
sportc=Segment_port[1];
sporta=Segment_port[0];
ColCount++;
}
//--------------------------------------
// Convet HEX 2 byte to 7-Segment code
//--------------------------------------
void HTO7S(unsigned int32 Num)
{
unsigned int32 res;
Segment[0]=SegCode[30*Num/10230];
if (Segment[0]==0x40)
Segment[0]=0xFF;
res = 30*Num%10230;
Segment[1]=SegCode[10*res/10230];
res=10*res%10230;
Segment[2]=SegCode[10*res/10230];
//! Segment[0]=SegCode[1];
//! Segment[1]=SegCode[2];
//! Segment[2]=SegCode[5];
} |
[img]
http://www.coolcircuit.com/project/meter/circuit.gif[/img]
without resistor and transistor |
I have need read more then 1 adc, but no left adc pin on this code. If i use 7447 BCD to 7 Segment driver IC, then it possible with above code ?
LIKE THIS WAY Code: |
_______
vdd | 1 14 | Vss
DIGIT_1000 <-- RA5 | 2 13 | AN0 <-- ADC0
DIGIT_100 <-- RA4 | 3 12 | AN1 <-- ADC1
MCLR | 4 11 | AN2 <-- ADC2
DIGIT_10 <-- RC5 | 5 10 | RC0 --> A
DIGIT_0 <-- RC4 | 6 9 | RC1 --> B
D <-- RC3 | 7 8 | RC2 --> C
_______ |
anybody can guide me ? _________________ sahu |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
Re: voltmetre numerique a 7 seg |
Posted: Sat Dec 27, 2014 3:34 am |
|
|
sahu77 wrote: | I have need read more then 1 adc, but no left adc pin on this code. If i use 7447 BCD to 7 Segment driver IC, then it possible with above code ?
LIKE THIS WAY Code: |
_______
vdd | 1 14 | Vss
DIGIT_1000 <-- RA5 | 2 13 | AN0 <-- ADC0
DIGIT_100 <-- RA4 | 3 12 | AN1 <-- ADC1
MCLR | 4 11 | AN2 <-- ADC2
DIGIT_10 <-- RC5 | 5 10 | RC0 --> A
DIGIT_0 <-- RC4 | 6 9 | RC1 --> B
D <-- RC3 | 7 8 | RC2 --> C
_______ |
anybody can guide me ? |
Yes, of course, you can with modified code.
Might be simpler to use a bigger PIC, but I'm sure you'll do it your way.
You've been down this road many times before, so it should be easy.
Mike |
|
|
sahu77
Joined: 08 Sep 2011 Posts: 202
|
Re: voltmetre numerique a 7 seg |
Posted: Sat Dec 27, 2014 12:14 pm |
|
|
Mike Walne wrote: | sahu77 wrote: | I have need read more then 1 adc, but no left adc pin on this code. If i use 7447 BCD to 7 Segment driver IC, then it possible with above code ?
LIKE THIS WAY Code: |
_______
vdd | 1 14 | Vss
DIGIT_1000 <-- RA5 | 2 13 | AN0 <-- ADC0
DIGIT_100 <-- RA4 | 3 12 | AN1 <-- ADC1
MCLR | 4 11 | AN2 <-- ADC2
DIGIT_10 <-- RC5 | 5 10 | RC0 --> A
DIGIT_0 <-- RC4 | 6 9 | RC1 --> B
D <-- RC3 | 7 8 | RC2 --> C
_______ |
anybody can guide me ? |
Yes, of course, you can with modified code.
Might be simpler to use a bigger PIC, but I'm sure you'll do it your way.
You've been down this road many times before, so it should be easy.
Mike |
thank u sir ,give me to show confidence .
i want to learn to use 7447 BCD to 7 Segment driver IC pic mcu.
pl guide me _________________ sahu |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Sat Dec 27, 2014 12:20 pm |
|
|
gpsmikey wrote: | Could be worse - with gravel, you get tired, you take a break, have a cold one then get back to work. Now, if it was concrete, you just have to move faster and KEEP MOVING !!!
mikey |
and it gets really fun when your shovel breaks.
(had this happen years ago - redi mix delivery, started shifting it...). Rude language at this point. |
|
|
sahu77
Joined: 08 Sep 2011 Posts: 202
|
Re: voltmetre numerique a 7 seg |
Posted: Sat Dec 27, 2014 3:12 pm |
|
|
Mike Walne wrote: | sahu77 wrote: | I have need read more then 1 adc, but no left adc pin on this code. If i use 7447 BCD to 7 Segment driver IC, then it possible with above code ?
LIKE THIS WAY Code: |
_______
vdd | 1 14 | Vss
DIGIT_1000 <-- RA5 | 2 13 | AN0 <-- ADC0
DIGIT_100 <-- RA4 | 3 12 | AN1 <-- ADC1
MCLR | 4 11 | AN2 <-- ADC2
DIGIT_10 <-- RC5 | 5 10 | RC0 --> A
DIGIT_0 <-- RC4 | 6 9 | RC1 --> B
D <-- RC3 | 7 8 | RC2 --> C
_______ |
anybody can guide me ? |
Yes, of course, you can with modified code.
Might be simpler to use a bigger PIC, but I'm sure you'll do it your way.
You've been down this road many times before, so it should be easy.
Mike |
thank u sir, i got it. but i have to need display letter U in 7 segment, that is not possible 7447. Its may possible with 74595. can u help me
74595 with 16f676 as
Code: |
_______
vdd | 1 14 | Vss
DIGIT_1000 <-- RA5 | 2 13 | AN0 <-- ADC0
DIGIT_100 <-- RA4 | 3 12 | AN1 <-- ADC1
MCLR | 4 11 | AN2 <-- ADC2
DIGIT_10 <-- RC5 | 5 10 | RC0 --> DS
DIGIT_0 <-- RC4 | 6 9 | RC1 --> ST_CP
<-- RC3 | 7 8 | RC2 --> SH_CP
_______
|
_________________ sahu |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Sat Dec 27, 2014 3:55 pm |
|
|
CCS does supply a driver for the 74595 in the drivers folder. Since you're only using one 74959 you can reduce the code a bit, clean it up a bit to make it easier to read,understand and execute.
The 'basics' of it is that your program fill the variable 'eo' with the bit pattern you want the 595 to output. the driver then sets/clrs the bits as required then send the 'data stream' to the 595.Since a 7segment display only needs 7 bit, I'd use bit 0 to be 'a', bit1 to be 'b', bit7 to be 'g'.
You'll need a 'table' of character to segments to translate say the number '3' into the appropriate bits ( a,b,c,d,g), which then goes to 'eo,then call the driver. As you have full control over the segments, you can easily code in 'U'.
I suggest you practice with a simple program to loop the numbers 0 to 9 and display them,then, add in 'U' and other characters as required. This program becomes your 'function' to display any character.
You'll then have to cut code to enable the 'drive transistor' to control the 1000,100,10,1 digit by some multiplexing/scanning scheme.
start small, get the 1's digit to do what you want THEN proceed....
jay |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|