• AVR Freaks

remove a zero

Page: << < ..678 > Showing page 7 of 8
Author
Gort2015
Klaatu Barada Nikto
  • Total Posts : 4014
  • Reward points : 0
  • Joined: 2015/04/30 10:49:57
  • Location: 0
  • Status: offline
Re: remove a zero 2018/03/03 16:05:35 (permalink)
0
if(!--cnt)

to

if(!cnt--)

MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
https://www.youtube.com/watch?v=Iu1qa8N2ID0
+ ST:Continues, "What Ships are Made for", Q's back.
kurt
Senior Member
  • Total Posts : 121
  • Reward points : 0
  • Joined: 2017/05/07 13:18:17
  • Location: 0
  • Status: offline
Re: remove a zero 2018/03/05 14:19:57 (permalink)
0
that oscillator and calculating average, it works now. but while i was testing and comparing my projects with other projects on the internet i discovered that my leds are not so bright. but first to know, my project looks like this  lm7805 which powers the pic18f2220, a temperature sensore and four 7 segments displays (kingbright sc39-11ewa)
to display the temperature.  In order to find out what this could be i did first some measurements:
output of the lm7805 is 4.95 volt.  output pins on pic that are used for multiplexing 4.01 volt. currentflow from output pin of pic for multiplexing is 13.5 ma. and i verified that the indicated resistance of resistor is indeed  nearby 150 ohm varies from 147 to 154.
a quick calculation on this one is U=I * R  so  4.01 =  0.0135 * 150 but this is not matching because
0.0135 *150 = 2.025 and not 4.01 how is this possible
i did the measurement with multiplexing set to 400 ms instead of 4 ms,  but same result 
is there an explanation for this 
 
qɥb
Monolothic Member
  • Total Posts : 3332
  • Reward points : 0
  • Joined: 2017/09/09 05:07:30
  • Location: Jupiter
  • Status: offline
Re: remove a zero 2018/03/05 14:54:03 (permalink)
+2 (2)
kurt
...
a quick calculation on this one is U=I * R  so  4.01 =  0.0135 * 150 but this is not matching because
0.0135 *150 = 2.025 and not 4.01 how is this possible
...

Where are you allowing for the voltage drop across the LED?
 

This forum is mis-configured so it only works correctly if you access it via https protocol.
The Microchip website links to it using http protocol. Will they ever catch on?
PicForum "it just works"
Gort2015
Klaatu Barada Nikto
  • Total Posts : 4014
  • Reward points : 0
  • Joined: 2015/04/30 10:49:57
  • Location: 0
  • Status: offline
Re: remove a zero 2018/03/05 19:16:00 (permalink)
0
And...You allowed then to fade out, they are not refreshed fast enough.
50hz to 100hz (ideal).  Adjust until they are static.
 

MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
https://www.youtube.com/watch?v=Iu1qa8N2ID0
+ ST:Continues, "What Ships are Made for", Q's back.
kurt
Senior Member
  • Total Posts : 121
  • Reward points : 0
  • Joined: 2017/05/07 13:18:17
  • Location: 0
  • Status: offline
Re: remove a zero 2018/03/06 15:13:32 (permalink)
0
voltage drop across the led?  I do something wrong i just don't know what 
i need to figure it out and come back to it later
 
qɥb
Monolothic Member
  • Total Posts : 3332
  • Reward points : 0
  • Joined: 2017/09/09 05:07:30
  • Location: Jupiter
  • Status: offline
Re: remove a zero 2018/03/06 15:16:42 (permalink)
0
kurt
voltage drop across the led?  I do something wrong i just don't know what 
i need to figure it out and come back to it later

Where is the problem?
You calculated the voltage across the series resistor, but ignored the voltage drop across the LED.
 

This forum is mis-configured so it only works correctly if you access it via https protocol.
The Microchip website links to it using http protocol. Will they ever catch on?
PicForum "it just works"
kurt
Senior Member
  • Total Posts : 121
  • Reward points : 0
  • Joined: 2017/05/07 13:18:17
  • Location: 0
  • Status: offline
Re: remove a zero 2018/03/06 15:31:16 (permalink)
0
i measured voltage at the output pin of my pic and the ground
qɥb
Monolothic Member
  • Total Posts : 3332
  • Reward points : 0
  • Joined: 2017/09/09 05:07:30
  • Location: Jupiter
  • Status: offline
Re: remove a zero 2018/03/06 15:43:34 (permalink)
0
Isn't the current from the PIC pin passing through both a resistor and an LED to get to ground?
 

This forum is mis-configured so it only works correctly if you access it via https protocol.
The Microchip website links to it using http protocol. Will they ever catch on?
PicForum "it just works"
Gort2015
Klaatu Barada Nikto
  • Total Posts : 4014
  • Reward points : 0
  • Joined: 2015/04/30 10:49:57
  • Location: 0
  • Status: offline
Re: remove a zero 2018/03/06 16:17:49 (permalink)
0
Very simple to calculate.
R = (V - VDROP) / CURRENT
150 ohms = (5v - 2v) / .02ma
 
 
 
 
 
 

MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
https://www.youtube.com/watch?v=Iu1qa8N2ID0
+ ST:Continues, "What Ships are Made for", Q's back.
dan1138
Super Member
  • Total Posts : 4173
  • Reward points : 0
  • Joined: 2007/02/21 23:04:16
  • Location: 0
  • Status: offline
Re: remove a zero 2018/03/06 16:24:07 (permalink)
+1 (1)
From what I can understand of the design that Kurt has posted the present problem concerns the brightness of the 7-segment LED displays.
 
The circuit that drives a single segment appears to be from the PIC GPIO output to a 150 ohm resistor to the LED segment to an NPN transistor to ground.
 
Kurt posted that the PIC output voltage is 4.01 volts and the current is 13.5 mA.
 
If we consider these measurements as accurate then the voltage across the 150 ohm resistor is (150 * 0.0135) 2.025 volts. The remaining 1.985 volts, (4.01-2.025) must be across the LED segment and NPN transistor.
 
The a forward voltage drop of 1.985 volts at 13.5 mA is consistent with the SC39-11EWA data sheet.
 
I would recommend that Kurt test the SC39-11EWA brightness using a 5.0 volt power source, a resistor and a volt meter to measure the voltage across the resistor. Change the value of the resistor until you see the brightness to need. Once you have found a resistor value for the brightness you need you will want to divide the value by the number of displays you will multiplex.
 
For example, if you find the brightness you want using a 500 ohm resistor then use a 125 ohm resistor with your PIC circuit.
 
Gort2015
Klaatu Barada Nikto
  • Total Posts : 4014
  • Reward points : 0
  • Joined: 2015/04/30 10:49:57
  • Location: 0
  • Status: offline
Re: remove a zero 2018/03/06 17:15:30 (permalink)
0
If you want to solve all the refresh problems, use one of these:
Maxim Integrated MAX7219 or MAX7221.
 
One device will scan up to 8 7-segment leds and takes all the work away from the mpu.
No interrupts.
 
It does bar-graphs, 64 individual leds and would also work with an 8x8 matrix.
 
I've used them and you get perfect static displays.

MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
https://www.youtube.com/watch?v=Iu1qa8N2ID0
+ ST:Continues, "What Ships are Made for", Q's back.
kurt
Senior Member
  • Total Posts : 121
  • Reward points : 0
  • Joined: 2017/05/07 13:18:17
  • Location: 0
  • Status: offline
Re: remove a zero 2018/03/25 12:18:04 (permalink)
0
i've started a new project with a pic18f45k20, but i noticed something strange,  it looks like there is already software on it, is there also a possibility to see what software is programmed on the pic.  that you can extract it from the pic 
qɥb
Monolothic Member
  • Total Posts : 3332
  • Reward points : 0
  • Joined: 2017/09/09 05:07:30
  • Location: Jupiter
  • Status: offline
Re: remove a zero 2018/03/25 12:24:22 (permalink)
0
kurt
i've started a new project with a pic18f45k20, but i noticed something strange,  it looks like there is already software on it, is there also a possibility to see what software is programmed on the pic.  that you can extract it from the pic

If the chip is not code protected, you can read out the machine code from it as a hex file, and examine the assembly instructions. There's no way of recovering the original source if it was written in C.
 

This forum is mis-configured so it only works correctly if you access it via https protocol.
The Microchip website links to it using http protocol. Will they ever catch on?
PicForum "it just works"
kurt
Senior Member
  • Total Posts : 121
  • Reward points : 0
  • Joined: 2017/05/07 13:18:17
  • Location: 0
  • Status: offline
Re: remove a zero 2018/03/26 12:46:12 (permalink)
0
with my pic 18f45k20 if i use b output for multiplexing all outputs work except output rb5 (thought it was this one)
if i make this output high and connect it to the segment of the digit al the other turned on segments of the digits are going to shine less bright.  
anyone an idea
qɥb
Monolothic Member
  • Total Posts : 3332
  • Reward points : 0
  • Joined: 2017/09/09 05:07:30
  • Location: Jupiter
  • Status: offline
Re: remove a zero 2018/03/26 14:20:53 (permalink)
0
Sorry, a verbal description of what you THINK you have done is useless.
Real code, and real schematic, will let us know what you have really done, and possibly suggest what the problem is.
 

This forum is mis-configured so it only works correctly if you access it via https protocol.
The Microchip website links to it using http protocol. Will they ever catch on?
PicForum "it just works"
kurt
Senior Member
  • Total Posts : 121
  • Reward points : 0
  • Joined: 2017/05/07 13:18:17
  • Location: 0
  • Status: offline
Re: remove a zero 2018/03/27 10:34:34 (permalink)
+1 (1)
i think i need to order a new pic
qɥb
Monolothic Member
  • Total Posts : 3332
  • Reward points : 0
  • Joined: 2017/09/09 05:07:30
  • Location: Jupiter
  • Status: offline
Re: remove a zero 2018/03/27 13:37:29 (permalink)
0
So you're unwilling to show us your schematic and code?
 

This forum is mis-configured so it only works correctly if you access it via https protocol.
The Microchip website links to it using http protocol. Will they ever catch on?
PicForum "it just works"
dan1138
Super Member
  • Total Posts : 4173
  • Reward points : 0
  • Joined: 2007/02/21 23:04:16
  • Location: 0
  • Status: offline
Re: remove a zero 2018/03/28 16:07:53 (permalink)
0
qɥb
So you're unwilling to show us your schematic and code?

 
There is perhaps little difference between unable and unwilling in this circumstance.
In post #42 there is code that could do what the OP has asked for, yet there is no evidence that the OP has ever tried to build this code.
kurt
Senior Member
  • Total Posts : 121
  • Reward points : 0
  • Joined: 2017/05/07 13:18:17
  • Location: 0
  • Status: offline
Re: remove a zero 2018/03/30 08:11:42 (permalink)
0
no it's not unable or unwilling but the code in #42 is way above my level it's totally new for me and if possible i want to do it as much as possible myself (with some help).  if i just copy and paste the code in my mplab,  sure it works but i dont understand one thing of it. Now i'am constructing pieces of code i understand and see if the code in works in real (see pictures attached) with this i encounter problems and try to solve it. i don't get the feeling that i'am not serious with it although i must say that due to my 'amateur' programming skills sometimes it seems to be so.   
 
for dan1138,  what's your opinion about my methode?
 
in my previous posts about that one segment didn't work i googled a lot and red something about the LVP bit in the configuration bits, so i've set this off and it worked 
 
underneath is my 'concept'  code,  i want the value 9234 to be showed on the four digits   but it only shows the nine 
i don't know what it is.  the code is reconstructed from the temperature meter only now with common anode instead of common cathode.  sometimes i get the feeling that the pic itself is not oke.  at the end of my multiplexing lines i add the code to make LA2=1;   to make this output high and see in this way if the code comes to here i connected a led to this output but it don't become high. but in proteus it works  there is something wrong.  anyone ideas
 
 
 

#include "header.h" /* Configuration settings Before anything else. */
#include <xc.h> /* Device support header file, if not already included. */

#include <stdlib.h>
#include <delays.h>
#include <ctype.h>
#include <capture.h> /* Peripheral library for PIC18 devices. */
#include <timers.h> /* Peripheral library for PIC18. */
//#include "interruptfile.h"
#define _XTAL_FREQ 4000000 
//LCD Pins
/* Use LATx register on devices where LATx register exists. */
#define Digit1 PORTDbits.RD0
#define Digit2 PORTDbits.RD1
#define Digit3 PORTDbits.RD2
#define Digit4 PORTDbits.RD3
#define Digit5 PORTDbits.RD4
#define Digit6 PORTDbits.RD5
#define delay 60
unsigned long int cap_val = 0;
unsigned long int rev = 0;
unsigned long int tussenrev = 0;
unsigned char Display(unsigned char digit)
{
unsigned char pattern; //{ 0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F } // for common cathode
unsigned char SEGMENT_MAP[10] = { 0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x02, 0xF8, 0x80, 0x90 };// for common anode
pattern = SEGMENT_MAP[digit]; //The pattern to return
return (pattern);
}
void main(void)
{
unsigned char ASD, BSD, CSD, DSD, ESD, FSD;
TRISA = 0x00;// self included xxx 
TRISB = 0x00;
TRISD = 0x00;
TRISC = 0xFF;
OSCCON = 0x50;

while(1)
{ rev = 9234; // value to be displayed 
{
if (PORTCbits.RC1 == 0) // some test to see if the code runs
{ LATAbits.LA1=1; }

else 
{ LATAbits.LA1=0;} 

}
ASD = (rev / 1000) % 10; 
LATB = Display(ASD); 
Digit1 = 0; 
__delay_ms(delay); 
Digit1 = 1; 

BSD = (rev / 100) % 10; 
LATB = Display(BSD); 
Digit2 = 0; 
__delay_ms(delay); 
Digit2 = 1;
CSD = (rev / 10) % 10;
LATB = Display(CSD);
Digit3 = 0;
__delay_ms(delay);
Digit3 = 1;
LATAbits.LA2=1;  // to test if the loop comes to here
DSD = (rev / 1) % 10; 
LATB = Display(DSD);
Digit4 = 0;
__delay_ms(delay);
Digit4 = 1; 
}
}
 
 
 

Attachment(s)

Attachments are not available: Download requirements not met
Gort2015
Klaatu Barada Nikto
  • Total Posts : 4014
  • Reward points : 0
  • Joined: 2015/04/30 10:49:57
  • Location: 0
  • Status: offline
Re: remove a zero 2018/03/30 09:30:56 (permalink)
0
Just found some old 8bit code that displays a 2 digit number.
It uses an interrupt to refresh the display.  A timer turns off the display after a set time.
Each time the interrupt is called only 1 digit is refreshed.
On the next interrupt the 2nd digit is refreshed.
1-2-1-2 etc
 
With 4
1-2-3-4-1-2-3-4 etc
 
if(PIE1bits.TMR2IE&PIR1bits.TMR2IF){  //refresh display
       PIR1bits.TMR2IF=false;
       if(!--display_timeout){  //display off
            T2CONbits.TMR2ON=false;
            LATA=0; LATD=0;
            display_timeout=dft_display_timeout;
            return;
       }
       if(display_timeout&1){
           LATA|=D2;
           LATA&=~D1;
           DISPLAY=Segment[BCD>>4];
       }
       else {
           LATA|=D1;
           LATA&=~D2;
           DISPLAY=Segment[BCD&0xf];
       }
}



const ubyte Segment[]={0x3f,0x6,0x5b,0x4f,0x66,0x6d,0x7c,0x7,0x7f,0x67,//0-9
                                     0x79,0x71,0x39,0x77},//E,F,C,A


 
DISPLAY is a Latch port.
BCD a number between 00 and 99
D1, D2 a mask to turn each led display on or off.

MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
https://www.youtube.com/watch?v=Iu1qa8N2ID0
+ ST:Continues, "What Ships are Made for", Q's back.
Page: << < ..678 > Showing page 7 of 8
Jump to:
© 2021 APG vNext Commercial Version 4.5