Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] PIC18F452 simple Counter project help

Status
Not open for further replies.

samsam_91

Newbie level 1
Newbie level 1
Joined
May 10, 2014
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
15
Hello everyone

I found you guys the best website have a good information and supporting members , so I hope you can help me in this simple project that requested from me in the college :)

I`m using a PIC18F452,
The coding by BASIC "Proton IDE"
the goal of project is "make a counter of 3 digits count to 999 and there's a 3 switches 1 make an up counting 2nd make a down and 3rd stop or held this operation "

I made the code and I got some errors in 7 seg reading

there is the code


Code Basic4GL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Device 18F452
XTAL 4
ALL_DIGITAL 1
Dim X As Byte
Output PORTD
Output PORTA
Dim n0,n1,n2,d0,d1,d2 As Byte
label: 
For d2=0 To 9 Step 1
For d1=0 To 9 Step 1
For d0=0 To 9 Step 1
For X=0 To 40 Step 1
PORTA=%11011111
n0=LookUpL d0,[0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90]
PORTD=n0
DelayMS 10
PORTA=0xff
n1=LookUpL d1,[0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90]
PORTD=n1
PORTA=%11101111
DelayMS 10
PORTA=0xff
n2=LookUpL d2,[0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90]
PORTD=n2
PORTA=%11111111
DelayMS 10
PORTA=0xff
Next X
Next d0
Next d1
Next d2
GoTo label
End




and the circuit
project.png


*** And I just want to know is the error in coding or the circuit ??

Thanks,
 
Last edited by a moderator:

there's a 3 switches 1 make an up counting 2nd make a down and 3rd stop or held this operation
Well,there are only two switches,with resistor(s) R3 and R2 connected to RB2 and RB3,respectively.Where is the third switch in the circuit diagram?
 

PORTA=%11011111
This takes pin A5 low.

Digit zero common is on A0, so I would expect:
Code:
PORTA=%11111110
(I assume that your BASIC compiler accepts binary numbers with bit 0 last, but I am not familiar with that compiler)

You are probably over-driving the PIC outputs. Properly designed circuits have current limiting resistors and transistors for the 7-seg LED display.

Your schematic shows no external crystal and no other means of providing a clock to the CPU. PIC18F452 has no internal oscillator option, so some form of external clock circuitry is needed.

None of this matters to Proteus, as it does not simulate the real world, but that schematic will not work for real hardware.
 
Last edited:

There are a few problems with this circuit. Will you be building this circuit or just simulating it?

1. You never set any TRIS bits as inputs. So you do not have any inputs. From the code it looks like you are only trying to get the counting part working.
2. In real hardware you will need to add a crystal, which can only go on two pins.
3. In real hardware you do not want to connect the digits com pins directly to the PIC. You will need a current sink of some form.
4. Since this display is multiplexed you can only have one digit on at a time. You will need to scan through them. If you scan fast enough it will look like they are all on.

This site contains a few good tutorials:
http://digital-diy.com/Table/proton-basic/proton-basic-example/

I hope this helped.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top