Hi, i am relatively new to simulide.
I watched its development some time but did not know enough about electronics and microcontroller to use it.
Now I think my knowledge has evolved, it tried the simulator and had some good results with my project. But now i am stuck a bit.
For one project i would like to simulate an attiny13(a) and programming it with Great Cow BASIC, reading an LDR and blinking a LED. The LED-Part works so far.
Q1: For the LDR-Part i had a software serial solution on the real hardware. This won't work with simulide, wouldn't it? My first attempt to open the serial monitor led to a crash of the simulide-program. Maybe someone knows a trick.
Q2: With respect to the LDR: it gave me readings of 255 which means 100% @3Volts in the simulation. After refining the circuit, it shows a zero in the variable. Could someone give me a hint how to change the values or howto fix the circuitry?
Q3: In the same program i am working with the watchdog - this seems not to work as well. Or do i have to tweak some Settings to see the watchdog work?
In the same project, i had originally a radio transmitting solution for transmitting the ldt measurements by "misusing" the softwareserial. I wanted to try some kind of manchester encoding and refine the solution.
Q4: Do I have any chances in building a circuit with two microcontroller one as sender and one as receiver? Did not try it, but thought i ask in advance before wasting time with a simulation which won't work in the end.
Here is the Code i am using at the moment:
And here is the circuit:
Thank you in advance - any help is appreciated.
I watched its development some time but did not know enough about electronics and microcontroller to use it.
Now I think my knowledge has evolved, it tried the simulator and had some good results with my project. But now i am stuck a bit.
For one project i would like to simulate an attiny13(a) and programming it with Great Cow BASIC, reading an LDR and blinking a LED. The LED-Part works so far.
Q1: For the LDR-Part i had a software serial solution on the real hardware. This won't work with simulide, wouldn't it? My first attempt to open the serial monitor led to a crash of the simulide-program. Maybe someone knows a trick.
Q2: With respect to the LDR: it gave me readings of 255 which means 100% @3Volts in the simulation. After refining the circuit, it shows a zero in the variable. Could someone give me a hint how to change the values or howto fix the circuitry?
Q3: In the same program i am working with the watchdog - this seems not to work as well. Or do i have to tweak some Settings to see the watchdog work?
In the same project, i had originally a radio transmitting solution for transmitting the ldt measurements by "misusing" the softwareserial. I wanted to try some kind of manchester encoding and refine the solution.
Q4: Do I have any chances in building a circuit with two microcontroller one as sender and one as receiver? Did not try it, but thought i ask in advance before wasting time with a simulation which won't work in the end.
Here is the Code i am using at the moment:
- Code:
#chip tiny13a, 4.8
#define PWM_Out1 PortB.0
#define ADSpeed MediumSpeed
#define USE_AD1 TRUE
#define USE_AD0 FALSE
#define USE_AD2 FALSE
#define USE_AD3 FALSE
DIR PWM_Out1 OUT
DIR PortB.2 IN
'8s WDT x MAX_NUM = time before the main program is really executed
#DEFINE MAX_NUM 1 'set to 225 to do something every 30 min, debug set to 1 (8s WDT)
watchdog_off 'deactivate the watchdog, good practice
'Set Variables
DIM TIMEOUT, LDR AS BYTE
dim tblCounter1, tablecounter2 as byte
DIM Invalue1, invalue2 AS WORD
TIMEOUT = MAX_NUM 'set timer intervall - while the mcu mostly sleeps
ON INTERRUPT WDT CALL wdt_wakeup
do
wdt_sleep
TIMEOUT -= 1
IF TIMEOUT = 0 THEN
LDR = READAD(ADC1)
wait 30 us
LDR = READAD(ADC1)
IF LDR <= 60 THEN
for tblCounter1 = 1 to 120
for tblcounter2 = 1 to 35
ReadTable Brightness, tblCounter1, Invalue1
Readtable Timings, tblcounter2, Invalue2
PWMOut 1, invalue2, invalue1
wait invalue2 us
next
next
wait 500 us
TIMEOUT = MAX_NUM
ELSE
TIMEOUT = MAX_NUM
END IF
END IF
loop
SUB watchdog_off
INToff
wdr
MCUSR = 0b00000000
WDTCR = 0b00011000 'timed sequence to switch the WDT off
WDTCR = 0b00000000
INTon
END SUB
SUB watchdog_on
INToff
wdr
'WDT-Prescaler value = 8 s, WDT set to Interrupt (WDTIE) not reset
WDTCR=0b00011000
WDTCR=0b01111001
INTon
END SUB
SUB wdt_sleep
PRR = 0b0000011 'Timer0 and ADC off
DIDR0 = 0b00111111 'digital inputs off
watchdog_on
MCUCR=0b00110000 'sleep enable and mode poweroff
sleep
END SUB
SUB wdt_wakeup
MCUCR = 0b00000000 'sleep-enable off
PRR = 0b00000000 'Timer0 and ADC on
watchdog_off
END SUB
'generated random numbers for the brightness of the led, found that the table is more sufficient for timings
'did not change the name because it was easier while testing.
Table Brightness
842
970
796
428
501
818
838
425
947
674
481
578
808
166
612
721
184
1003
397
557
333
476
124
465
204
634
507
870
646
962
340
652
410
914
817
280
536
1006
199
523
374
467
149
688
337
959
259
819
411
991
815
716
837
366
1018
175
308
565
613
928
482
741
472
509
522
404
996
544
305
546
454
804
419
846
315
689
651
792
352
279
904
173
586
856
843
957
143
850
673
847
444
401
217
582
729
923
309
759
338
218
568
873
538
958
327
727
128
971
594
399
169
499
701
515
787
395
125
585
551
495
End Table
'generated random numbers for the timing of the led, found that the table is more sufficient for brightness
'did not change the name because it was easier while testing.
Table Timings
389
128
365
343
304
289
211
354
148
487
91
50
109
111
485
344
339
162
404
415
118
56
418
63
73
153
380
266
440
394
419
121
177
292
463
End Table
And here is the circuit:
Thank you in advance - any help is appreciated.