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.

[SOLVED] PWM Codes Proton/Proteus Problem

Status
Not open for further replies.

MyMelon

Member level 2
Joined
May 7, 2012
Messages
44
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,564
what's the problem with my code it tells a CPU overload in proteus do i have a problem in ckt or in program

code:

Device 16F628A
Xtal=20
All_Digital true
Symbol Led PORTB.3
Symbol sw1 PORTA.0
Symbol sw2 PORTA.1
Input sw1
Input sw2
Output PORTB


Dim x As Word
x=100
loop:
If sw1=0 Then x=x-10:DelayMS 200
If sw2=0 Then x=x+10:DelayMS 200
PWM Led,x,1000
GoTo loop

https://imageshack.us/photo/my-images/201/pwmh.jpg/
 

What frequency do you specify the crystal to run at? if you specify a crystal frequency to accurately such as 3.6868MHz you will get this error, 3.686Mhz will work fine.
 

i use 20Mhz on external clock but i don't think that will work because proteus have already built in external clock so that one can be remove,.
the set the internal clock to 4mhz, 10mhz and 20mhz for troubleshooting but it won't work:-|

- - - Updated - - -

what's the difference of pwm and hpwm in a codes? i get excessive cpu load in the first code



code in PWM

Device=16F628A
Xtal=20
All_Digital true
Symbol LED PORTB.3
Symbol SW1 PORTB.0
Symbol SW2 PORTB.1
Input SW1
Input SW2
Output LED

Dim x As Byte
x=100
loop:
If SW1=0 Then x=x-10:DelayMS 200
If SW2=0 Then x=x+10:DelayMS 200
PWM LED,x,1000 <-------------------------------------------------
GoTo loop


Codes for HPWM

Device 16F628A
Xtal=20
All_Digital true
LCD_DTPin PORTB.4
LCD_RSPin PORTB.0
LCD_ENPin PORTB.1
Symbol Led PORTB.3
Output Led


CCP1_Pin PORTB.3
Dim x As Byte
PORTB=0
HPWM 1,50,1000 <-------------------------------------------------
Cls
Print At 2,1,"PWM ON"
loop:
For x=0 To 255
Print At 1,1,Dec3,x
DelayMS 200
Next x
GoTo loop
 

The message "simulation is not running in real time due to excessive CPU load" (is this the error you are getting?) simply means that the simulation requires more than the available processing power to simulate the circuit as it happens in real time. This often occurs when you mix digital and analogue circuits together, (even the oscilloscope is an analogue component). This is nothing to worry about as the circuit will work fine in real life. Often the simulation runs so slowly that it may be a good idea to remove delay loops so that the simulator will respond in a timely manner, remembering of course to put back the delay loop when you program the PIC.
 

tnx a lot. just another question what CPU is processing when simulating is it my real CPU installed in Computer or the Proteus itself that have a processing issue?
 

Unfortunately Proteus and all other electronic simulators I have tried are single threaded so when you look in task manager when you get this warning message you will find that one of your cores will be running flat out.
So to answer your question it is your processor that is not fast enough. In simulations that I do I would need a processor at least 1000 times faster to be able to simulate in real time. When you think about it when you have both digital and analogue parts running in the same circuit to be simulated, the simulator has to simulate the entire analogue circuit every clock cycle of the simulated digital circuit and if the clock is in the MHZ range that will take a lot of processing power.
 
Last edited:

Hi MYMelon;

Just a suggestion:

- remove the following components in your DSN (in Proteus they are unnecessary):
R1, R2 with the reset switch, R3 (= 0 Ohm), C1, C2, C3, X1

- modify R4 and R12 type to DIGITAL or PULLUP (instead of ANALOGUE)

and the simulation will be much faster.
zuisti
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top