Pulse Generator Circuit Questions

Thread Starter

elec_system_design

Joined Jun 23, 2017
49
hi,
Make R3 470R and R5 100R, check current thru R5.
E
Hi Eric,

With those changes, we get 50mA during the on phase. That's definitely sufficient for the LED considering the 20mA requirement.

However, I'm still not sure how much the servo requires. It's a POP 9G SG90 Micro Servo motor, but I can't seem to find a detailed datasheet on it.
 

ericgibbs

Joined Jan 29, 2010
21,448
hi,
This is a sim showing the modified circuit.

E

EDIT:
Add a 39R in series with C2, reduce the initial current thru Q1 and still keep the sharper cut off.
 

Attachments

Last edited:

Thread Starter

elec_system_design

Joined Jun 23, 2017
49
hi,
This is a sim showing the modified circuit.

E

EDIT:
Add a 39R in series with C2, reduce the initial current thru Q1 and still keep the sharper cut off.
Hi,

I found the data on the servo: https://www.addicore.com/Addicore-SG90-Mini-Servo-p/113.htm

EDIT: Under the assumption that all SG90 motors have the same specifications.

As the circuit is now, we have an output current of ~193mA. It seems sufficient for the servo based on the 220 ±50mA running current, but not for the stall current. Though it doesn't seem like a relevant parameter for the circuit.

I planned to power the circuit with 4 AA batteries. Will I need to regulate the voltage to 5V, or would the circuit still work just fine with 6V, while dropping lower as the batteries drain?

Also, thanks for the help.
 

ericgibbs

Joined Jan 29, 2010
21,448
hi,
That is a higher current than I thought you required for the MPS.
As the duration is 40Secs and you have an initial 6V source from your battery pack which may reduce in use, I would consider switching a 5v relay.
E
 
Last edited:

Thread Starter

elec_system_design

Joined Jun 23, 2017
49
hi,
If you prefer to use MOS switching and not a relay, this is an alternative.
E
I'm not very familiar with using relays. Would it restrict me from using batteries?

The current output for this current circuit is significantly higher than before. Is that because of the need to power the MSP430, servo, and LED?

Also, I forgot that I wanted to have to connect the MSP430 with a Adafruit 0.56" 4-Digit 7-Segment Display w/I2C Backpack. Not sure how much this affects the circuit.
 

ericgibbs

Joined Jan 29, 2010
21,448
hi,
What do you think of the circuit in post #25?, it could supply upto 2Amps at close to +5V.
If you went for a relay option, there are 5Vdc relays that could switch upto 10A.

Let me know what you decide and we can finalise a circuit.

What is the purpose/use of the project.?
E

EDIT:
For ref:
pg6.asc and plot for relay option.
 

Attachments

Last edited:

Thread Starter

elec_system_design

Joined Jun 23, 2017
49
hi,
What do you think of the circuit in post #25?, it could supply upto 2Amps at close to +5V.
If you went for a relay option, there are 5Vdc relays that could switch upto 10A.

Let me know what you decide and we can finalise a circuit.

What is the purpose/use of the project.?
E

EDIT:
For ref:
pg6.asc and plot for relay option.
Hi Eric,

The purpose of the circuit is to power up an electronic lock box, so it will need to provide power to a seven segment display, power indicator LED circuit, and a servo to unlock the box. I also need to hook up a keypad to the input end of the MSP430.

I prefer not designing it with a relay if possible. My current issue is figuring out how much current I need to power all those parts up.

I like the circuit in #25, but the FDS6685 will be difficult for me since I only have plastic breadboards(FDS6685 doesn't seem to have a through hole version). Are there any alternative MOSFETs we could use? Also, how do we balance power efficient design, while being able to have the all the parts running properly? As it is right now, circuit #25 could potentially be providing more than enough current, it's mainly just the seven segment display I'm not sure about.

The relay is definitely impressive in terms of flexibility however. I would prefer the MOSFET circuit if the parts don't take up more than 2 amps. However, if it turns out to provide too little power, then it makes sense to go with the relay.
 

LesJones

Joined Jan 8, 2017
4,511
Now you have given the full story of it's intended function you could copy the automatic shutdown idea in this transistor tester. (The schematic is at the end of the page.) A push button causes it to power on. An output of the microcontroller then drives a transistor that maintains the power until a software timer in the microcontroller removes the drive to then transistor which shuts off all of the power. The only current consumed then is the leakage current of the switching transistor. I have copied this idea to switch off some LED lighting after a few minutes. I used this with an ATtiny13 and it works very well.

Les.
 

Thread Starter

elec_system_design

Joined Jun 23, 2017
49
Now you have given the full story of it's intended function you could copy the automatic shutdown idea in this transistor tester. (The schematic is at the end of the page.) A push button causes it to power on. An output of the microcontroller then drives a transistor that maintains the power until a software timer in the microcontroller removes the drive to then transistor which shuts off all of the power. The only current consumed then is the leakage current of the switching transistor. I have copied this idea to switch off some LED lighting after a few minutes. I used this with an ATtiny13 and it works very well.

Les.
That sounds great. Thanks for the suggestion, I will look into it.
 

ericgibbs

Joined Jan 29, 2010
21,448
hi elec,
If the 7 segment are LED types, they will be multiplexed/scanned so that only one LED digit is being powered at a time.
So if all 7 segs were lit and each drawing say 10mA, that's only ~70mA max at any one time.

Add up all the 'operating/running' currents, the start up/stall current for the motor could be ~650mA, so allow for that condition.

From what you have posted, I would say a 1.5A/2.0A current would be OK.

E
 

LesJones

Joined Jan 8, 2017
4,511
This is the scematic for my LED light timer.

Shutdown_timer_a.png


This is the code for the ATtint13A
Code:
;
/*
 * Shutdown timer  (Shutdown_timer03)  (To shut off a light after a preset period and also if the battery voltage is too low.)
 *
 *  Created: 03/09/2015
 *  Author: Les
 *  Version 2 being modified by adding low battery warning light
 */
 ;   using ATTINY13
; Fuse bit settings
 ; Low       0x62  (0x6A is also OK)
 ; High      0xFF
 ; Extended    0xFF
 ; Lock       0xFF
 ;
;

;Use internal clock at 9.6 Mhz  (Default value) and divide by 8 by setting CKDIV8 fuse bit (These are the default setting on a new chip.)
; 9.6 Mhz/8 = 1.2 Mhz
;(So Instruction time = 833.3 nS)

; So for 50 uS delay requires 50/0.8333 = 60 instructions

; Burst needs to be 5 mS long. This will be 50 cycles of 10 Khz

;
;**************************************************************************
.nolist
.include   <tn13def.inc>   ; ATtiny 13
.list
.listmac

;***************************************************************************
;*
;* Global Register Variables
;*
;***************************************************************************
; Note register number is in decimal

.def   N200mS     = r17   ;Number of 200 mS
.def   Seconds     = r18   ;Number of seconds
.def   Minutes     = r19   ;Number of minutes
.def   count_L     = r22   ;Used for time delay
.def   Flags     = r23   ;Bit 0 used for battery low warning flag

.equ   Shutdown_volts   = 0xA4   ;battery voltage shutdown value. (164 decimal. Divide battery voltage using a 4.7K resistor to ground and a 10 K resistor to the )
;  (collector ofthe power switching transistor. This gives a ratio of 0.32. So for a cut off voltage )
;  (of 10.0 we need to detect 3.2 volts This is 256 x 3.2/5 = 164 )
.equ   Battery_Low   = 0xB4   ;Battery voltage low warning level. (Set to come on at 11.0 volts so this will be 1.0 * 0.32 = 3.52 volts at ADC input
;                  (This will be a count of 256 * 3.52/5 = 180 = 0xB4 )
;
.equ   Shutdown_minutes = 5   ;Time to shutdown in minutes.
;
;
;******************************** INTERRUPT VECTORS ***********************
.CSEG
.ORG   00
     rjmp   reset
     reti
     reti
     rjmp    TC_overflow   ;Timer/Counter Overflow
     reti
     reti   ;   rjmp   timer1_OVF
     reti
     reti
     reti
     reti
;
;******************************* RESET *************************************
;   
; Initialise the stack-pointer   
reset:
         ldi   R16,low(RAMEND)
         out   SPL,R16

; initialize PORTB
;   Bit 0   Input  (pin 5)  (Input will be low when button is pressed.
;   Bit 1   Input
;   Bit 2   Input  ADC input (Pin 7)
;   Bit 3   Output  (Pin 2)  (Drive to low battery warning LED High for LED on)
;   Bit 4   Output   (Pin 3)  (Drive to power control tansistor base.)
;   Bit 5   Input

           ldi   R16,0x18   ; Bits 3 and 4 as outputs.
           out   DDRB,R16   ;
           ldi   R16,0x10
           out   PORTB,R16   ; PORTB Bit 3 low, bit 4 high

; initialize Flags
           ldi Flags,0x00
;Initialize ADC

           ldi R16,0x84       ;Enable ,  Prescale value 16,  No auto triggering
           out ADCSRA,R16

           ldi  R16,0b00000000
           out  ADCSRB,R16

           ldi R16,0x21   ;Select AD1 (pin 7) input, Select VCC as analogue reference. ADLAR (Left justify result)
           out ADMUX,R16


           ldi R16,0x04   ;Set PB2 as analoge input
           out DIDR0,R16

;Initialize timer / counter

           ldi R16,0x00       ;Normal operation
           Out TCCR0A,R16

           ldi R16,0x05       ;  Prescale value 1024 (Inc counter every 0.8333 uS x 1024 = 853.3 uS  (1171.88 hZ)
           Out TCCR0B,R16       ; Counter will overflow every 218.445 mS  (4,58 hZ)  
                       ; Counting to 234 would give 199.7 mS  ( 256 - 234 = 22 = 0x16)

           ldi R16,0x02       ;TOIE0 (Bit1) : Timer/Counter0 Overflow Interrupt Enable
           Out TIMSK0,R16

;Init time counters
           ldi N200mS,0x05
           ldi Seconds,0x00
           ldi Minutes,0x00

;Wait for button to be released  (Wait for input to go high

Wait_Button_High:
           sbis PINB,0
           rjmp Wait_Button_High

           bset 7     ;Enable global interrupst.
           rjmp main

;Timer/Counter Overflow interrupt handler.
TC_overflow:

           ldi R20,0x16     ;Preset timer so interrupt occures every 199.7 mS
           out   TCNT0,R20

           dec   N200mS ;200mS
           breq TC01
           RETI
TC01:
           ldi N200mS,0x05

Inc_Sec:       

           SBRS Flags, 0
           CBI PORTB,0x03     ;Clear battery low warning LED
           SBRS Flags,0     ;Bat_Warning   ;Skip if battery warning bit is set
           RJMP Inc_S2

           in R20,PORTB
           ldi R21,0x08     ;Bits 3
           eor R20,R21       ; Toggle bit 3 (Pin 2) (Every second)
           out PORTB,R20

Inc_S2:
           ldi R20,0x3C     ;60 decimal

           inc   Seconds       ;Increment seconds counter
           cpse Seconds,R20
           rjmp TC_End
           CLR Seconds

Inc_Min:
           ldi R20,0x3C     ;60 decimal

           inc   Minutes       ;Increment minute counter
           cpse Minutes,R20
           rjmp TC_End
           CLR Minutes

TC_End:
           RETI


;     ------------------------------------- End of interrupt handlers --------------------------------------

;
;  Main program code
;
Main:
       nop
       nop
       ldi R20,Shutdown_minutes
       cpse Minutes,R20         ;Is it time to shutdown ?
       rjmp Not_Time
       cbi PORTB,4             ;Clear PORTB bit 4
       rjmp End_Loop

Not_Time:
       nop
       nop
       nop
;       rjmp Main   ; Just loop waiting for interrupt

;Read ADC input value
           ldi R16,0x84       ;Enable ,  Prescale value 16,  No auto triggering
           out ADCSRA,R16

           ldi R16,0x21   ;Select AD1 input (pin 7) Select VCC as analogue reference, ADLAR (Left justify result)
           out ADMUX,R16

         sbi  ADCSRA,ADSC  ; Start ADC conversion
           nop
Wait_ADC_Ready:
           sbic  ADCSRA,ADSC  ; Wait_ADC_Ready:
           rjmp  Wait_ADC_Ready
           in R20,ADCL       ;Read ADC result L  (Value not used but need to read this register befor high byte.)
           in R20,ADCH       ;Read ADC result H

;Test for battery warning level
           CBR Flags,0x01 ;Bat_Warning       ;Clear battery warning flag

           CLC         ;Clear carry flag
           SBCI R20,Battery_Low
           BRBC 0x00,Test_Shutdown     ;Branch if carry bit is clear
           SBR Flags,0x01 ;Bat_Warning       ;Set battery warning flag bit

;Test for battery shutdown level
Test_Shutdown:
           in R20,ADCH       ;Read ADC result H again
           CLC         ;Clear carry flag
           SBCI R20,Shutdown_volts
           BRBS 0x00,Bat_Low       ;Branch if carry bit is set
           RJMP Bat_OK

Bat_Low:
           CBI PORTB,0x04       ; Shutdown

End_loop:
           NOP
           RJMP End_loop       ; Loop until power removed.

Bat_OK:
Test_button:               ;If button pressed input will be low.
           sbic   PINB,0

           rjmp Main   ; Just loop waiting for interrupt

;Now wait 100 mS and recheck that button is pressed. (De bounce switch contacts)
           rcall Delay_100ms
           sbic   PINB,0   
           rjmp Main
           cbi PORTB,4             ;Clear PORTB bit 4
           rjmp End_Loop

;Test_button:
           sbis   PINB,0
           rjmp   Test_button   ;Loop until button pressed

;Now wait 100 mS and recheck that button is pressed. (De bounce switch contacts)
           rcall Delay_100ms
           sbis   PINB,0   
           rjmp   Test_button   ;Loop until button is pressed

Button_open_loop:
           sbic   PINB,0   ;
           rjmp   Button_open_loop; loop until pedal released


;Subroutines.
;
;
;                 ----------------------------------------------
; Instruction cycle time is 0.83333 uS

; Delay 1mS  Rcall to get here takes 3 instruction cycles. ret instruction takes 4 instruction cycles, ldi takes 1 instruction cycle (total 8)

; For 1 mS (1000 uS) we need 1000/0.83333 = 1200 instructions  so need additional 1192 instructions  5 cycles in loop.


Delay_1_mS:
           ldi    count_L,0xEE   ;Decimal 238  0xEE (Once round the loop is 5 instructions)
D_1mS_Loop:
           dec   count_L     ; Count_L is R22  (1 cycle)
           nop         ;(1 cycle)
           nop         ;(1 cycle)
           brne    D_1mS_Loop   ;If not zero  (2 cycles while looping, 1 on exit)
           ret

Delay_100ms:
           ldi R21,0x64   ;100 decimal
Del_100ms_Loop:
           rcall Delay_1_mS
           dec R21
           brne Del_100ms_Loop
           ret

;  -------------End of subroutines --------------
;
There is code in the above listing to monitor the battery voltage which you wouldnot need.

Les.
 

Thread Starter

elec_system_design

Joined Jun 23, 2017
49
hi elec,
If the 7 segment are LED types, they will be multiplexed/scanned so that only one LED digit is being powered at a time.
So if all 7 segs were lit and each drawing say 10mA, that's only ~70mA max at any one time.

Add up all the 'operating/running' currents, the start up/stall current for the motor could be ~650mA, so allow for that condition.

From what you have posted, I would say a 1.5A/2.0A current would be OK.

E
The 7 segment display is an LED type. To add things all up, the 7 seg takes ~70mA, the motor takes ~650mA, the keypad takes ~100mA, and the RGB LED takes ~20mA. This adds up to around 840mA. I also wanted to add a simple LED circuit to switch the common anode RGB LED from green to red when the battery of the started running low. It doesn't seem like that would push us past the 1A supplied however. Would it be more advisable to provide a current of 1.5A?
 

ericgibbs

Joined Jan 29, 2010
21,448
hi,
It is important that the voltage supply to the MCU and logic circuits is not pulled below a safe operating level, when the motor is started or stalled.
If the voltage supply is pulled too low it could affect the reliability of the project.

I would have at least 50% over capacity on the available current for the voltage supply.
The 78S05 series of voltage regs will supply 2Amps.
Have you decided on the primary source of power.? is batteries ?

E
 

Thread Starter

elec_system_design

Joined Jun 23, 2017
49
This is the scematic for my LED light timer.

View attachment 134564


This is the code for the ATtint13A
Code:
;
/*
* Shutdown timer  (Shutdown_timer03)  (To shut off a light after a preset period and also if the battery voltage is too low.)
*
*  Created: 03/09/2015
*  Author: Les
*  Version 2 being modified by adding low battery warning light
*/
;   using ATTINY13
; Fuse bit settings
; Low       0x62  (0x6A is also OK)
; High      0xFF
; Extended    0xFF
; Lock       0xFF
;
;

;Use internal clock at 9.6 Mhz  (Default value) and divide by 8 by setting CKDIV8 fuse bit (These are the default setting on a new chip.)
; 9.6 Mhz/8 = 1.2 Mhz
;(So Instruction time = 833.3 nS)

; So for 50 uS delay requires 50/0.8333 = 60 instructions

; Burst needs to be 5 mS long. This will be 50 cycles of 10 Khz

;
;**************************************************************************
.nolist
.include   <tn13def.inc>   ; ATtiny 13
.list
.listmac

;***************************************************************************
;*
;* Global Register Variables
;*
;***************************************************************************
; Note register number is in decimal

.def   N200mS     = r17   ;Number of 200 mS
.def   Seconds     = r18   ;Number of seconds
.def   Minutes     = r19   ;Number of minutes
.def   count_L     = r22   ;Used for time delay
.def   Flags     = r23   ;Bit 0 used for battery low warning flag

.equ   Shutdown_volts   = 0xA4   ;battery voltage shutdown value. (164 decimal. Divide battery voltage using a 4.7K resistor to ground and a 10 K resistor to the )
;  (collector ofthe power switching transistor. This gives a ratio of 0.32. So for a cut off voltage )
;  (of 10.0 we need to detect 3.2 volts This is 256 x 3.2/5 = 164 )
.equ   Battery_Low   = 0xB4   ;Battery voltage low warning level. (Set to come on at 11.0 volts so this will be 1.0 * 0.32 = 3.52 volts at ADC input
;                  (This will be a count of 256 * 3.52/5 = 180 = 0xB4 )
;
.equ   Shutdown_minutes = 5   ;Time to shutdown in minutes.
;
;
;******************************** INTERRUPT VECTORS ***********************
.CSEG
.ORG   00
     rjmp   reset
     reti
     reti
     rjmp    TC_overflow   ;Timer/Counter Overflow
     reti
     reti   ;   rjmp   timer1_OVF
     reti
     reti
     reti
     reti
;
;******************************* RESET *************************************
;  
; Initialise the stack-pointer  
reset:
         ldi   R16,low(RAMEND)
         out   SPL,R16

; initialize PORTB
;   Bit 0   Input  (pin 5)  (Input will be low when button is pressed.
;   Bit 1   Input
;   Bit 2   Input  ADC input (Pin 7)
;   Bit 3   Output  (Pin 2)  (Drive to low battery warning LED High for LED on)
;   Bit 4   Output   (Pin 3)  (Drive to power control tansistor base.)
;   Bit 5   Input

           ldi   R16,0x18   ; Bits 3 and 4 as outputs.
           out   DDRB,R16   ;
           ldi   R16,0x10
           out   PORTB,R16   ; PORTB Bit 3 low, bit 4 high

; initialize Flags
           ldi Flags,0x00
;Initialize ADC

           ldi R16,0x84       ;Enable ,  Prescale value 16,  No auto triggering
           out ADCSRA,R16

           ldi  R16,0b00000000
           out  ADCSRB,R16

           ldi R16,0x21   ;Select AD1 (pin 7) input, Select VCC as analogue reference. ADLAR (Left justify result)
           out ADMUX,R16


           ldi R16,0x04   ;Set PB2 as analoge input
           out DIDR0,R16

;Initialize timer / counter

           ldi R16,0x00       ;Normal operation
           Out TCCR0A,R16

           ldi R16,0x05       ;  Prescale value 1024 (Inc counter every 0.8333 uS x 1024 = 853.3 uS  (1171.88 hZ)
           Out TCCR0B,R16       ; Counter will overflow every 218.445 mS  (4,58 hZ) 
                       ; Counting to 234 would give 199.7 mS  ( 256 - 234 = 22 = 0x16)

           ldi R16,0x02       ;TOIE0 (Bit1) : Timer/Counter0 Overflow Interrupt Enable
           Out TIMSK0,R16

;Init time counters
           ldi N200mS,0x05
           ldi Seconds,0x00
           ldi Minutes,0x00

;Wait for button to be released  (Wait for input to go high

Wait_Button_High:
           sbis PINB,0
           rjmp Wait_Button_High

           bset 7     ;Enable global interrupst.
           rjmp main

;Timer/Counter Overflow interrupt handler.
TC_overflow:

           ldi R20,0x16     ;Preset timer so interrupt occures every 199.7 mS
           out   TCNT0,R20

           dec   N200mS ;200mS
           breq TC01
           RETI
TC01:
           ldi N200mS,0x05

Inc_Sec:      

           SBRS Flags, 0
           CBI PORTB,0x03     ;Clear battery low warning LED
           SBRS Flags,0     ;Bat_Warning   ;Skip if battery warning bit is set
           RJMP Inc_S2

           in R20,PORTB
           ldi R21,0x08     ;Bits 3
           eor R20,R21       ; Toggle bit 3 (Pin 2) (Every second)
           out PORTB,R20

Inc_S2:
           ldi R20,0x3C     ;60 decimal

           inc   Seconds       ;Increment seconds counter
           cpse Seconds,R20
           rjmp TC_End
           CLR Seconds

Inc_Min:
           ldi R20,0x3C     ;60 decimal

           inc   Minutes       ;Increment minute counter
           cpse Minutes,R20
           rjmp TC_End
           CLR Minutes

TC_End:
           RETI


;     ------------------------------------- End of interrupt handlers --------------------------------------

;
;  Main program code
;
Main:
       nop
       nop
       ldi R20,Shutdown_minutes
       cpse Minutes,R20         ;Is it time to shutdown ?
       rjmp Not_Time
       cbi PORTB,4             ;Clear PORTB bit 4
       rjmp End_Loop

Not_Time:
       nop
       nop
       nop
;       rjmp Main   ; Just loop waiting for interrupt

;Read ADC input value
           ldi R16,0x84       ;Enable ,  Prescale value 16,  No auto triggering
           out ADCSRA,R16

           ldi R16,0x21   ;Select AD1 input (pin 7) Select VCC as analogue reference, ADLAR (Left justify result)
           out ADMUX,R16

         sbi  ADCSRA,ADSC  ; Start ADC conversion
           nop
Wait_ADC_Ready:
           sbic  ADCSRA,ADSC  ; Wait_ADC_Ready:
           rjmp  Wait_ADC_Ready
           in R20,ADCL       ;Read ADC result L  (Value not used but need to read this register befor high byte.)
           in R20,ADCH       ;Read ADC result H

;Test for battery warning level
           CBR Flags,0x01 ;Bat_Warning       ;Clear battery warning flag

           CLC         ;Clear carry flag
           SBCI R20,Battery_Low
           BRBC 0x00,Test_Shutdown     ;Branch if carry bit is clear
           SBR Flags,0x01 ;Bat_Warning       ;Set battery warning flag bit

;Test for battery shutdown level
Test_Shutdown:
           in R20,ADCH       ;Read ADC result H again
           CLC         ;Clear carry flag
           SBCI R20,Shutdown_volts
           BRBS 0x00,Bat_Low       ;Branch if carry bit is set
           RJMP Bat_OK

Bat_Low:
           CBI PORTB,0x04       ; Shutdown

End_loop:
           NOP
           RJMP End_loop       ; Loop until power removed.

Bat_OK:
Test_button:               ;If button pressed input will be low.
           sbic   PINB,0

           rjmp Main   ; Just loop waiting for interrupt

;Now wait 100 mS and recheck that button is pressed. (De bounce switch contacts)
           rcall Delay_100ms
           sbic   PINB,0  
           rjmp Main
           cbi PORTB,4             ;Clear PORTB bit 4
           rjmp End_Loop

;Test_button:
           sbis   PINB,0
           rjmp   Test_button   ;Loop until button pressed

;Now wait 100 mS and recheck that button is pressed. (De bounce switch contacts)
           rcall Delay_100ms
           sbis   PINB,0  
           rjmp   Test_button   ;Loop until button is pressed

Button_open_loop:
           sbic   PINB,0   ;
           rjmp   Button_open_loop; loop until pedal released


;Subroutines.
;
;
;                 ----------------------------------------------
; Instruction cycle time is 0.83333 uS

; Delay 1mS  Rcall to get here takes 3 instruction cycles. ret instruction takes 4 instruction cycles, ldi takes 1 instruction cycle (total 8)

; For 1 mS (1000 uS) we need 1000/0.83333 = 1200 instructions  so need additional 1192 instructions  5 cycles in loop.


Delay_1_mS:
           ldi    count_L,0xEE   ;Decimal 238  0xEE (Once round the loop is 5 instructions)
D_1mS_Loop:
           dec   count_L     ; Count_L is R22  (1 cycle)
           nop         ;(1 cycle)
           nop         ;(1 cycle)
           brne    D_1mS_Loop   ;If not zero  (2 cycles while looping, 1 on exit)
           ret

Delay_100ms:
           ldi R21,0x64   ;100 decimal
Del_100ms_Loop:
           rcall Delay_1_mS
           dec R21
           brne Del_100ms_Loop
           ret

;  -------------End of subroutines --------------
;
There is code in the above listing to monitor the battery voltage which you wouldnot need.

Les.
I may need to monitor the battery voltage, since I want my device to identify the condition of the battery. The electronic lock needs to remain active as it will be the only option to unlock the box.

The code you have is pretty interesting. I never knew that it was possible to code microcontrollers in assembly language.

Regardless, I think I'll stick with the design I've been discussing with Eric since we've been talking about it for quite a while and I wanted the timing to rely exclusively on hardware.

Thanks anyway, LesJones
 

Thread Starter

elec_system_design

Joined Jun 23, 2017
49
hi,
It is important that the voltage supply to the MCU and logic circuits is not pulled below a safe operating level, when the motor is started or stalled.
If the voltage supply is pulled too low it could affect the reliability of the project.

I would have at least 50% over capacity on the available current for the voltage supply.
The 78S05 series of voltage regs will supply 2Amps.
Have you decided on the primary source of power.? is batteries ?

E
I wanted to power the circuit with batteries, so it could be portable. The 78S05 sounds sufficient for this situation.
 

ericgibbs

Joined Jan 29, 2010
21,448
hi,
I would suggest that alkaline AAA batteries would not be suitable, consider 'C' or 'D' alkaline.
A 6v sealed lead acid [SLA] batteries, rated at 2A-hr or higher would be a better option, they are easily recharged with a simple charger and would IMO be more cost effective compared to replacing 'C' or 'D' type batteries.

When using a 6V SLA, the voltage will decrease down to approx 5.4v, then it will require a recharge.
[The alkaline batteries could decrease to 4.4v or less, so a regulated 5v would not be maintained]

Consider driving the MCU and logic circuits, using a low drop out reg [LDO] and the motor directly from the battery/s.
You calculate approx 200mA for the MCU etc, so a low power reg, say 500mA rated, would be OK.

There are other battery technologies you could consider , Li-Ion.

E
 

Thread Starter

elec_system_design

Joined Jun 23, 2017
49
hi,
I would suggest that alkaline AAA batteries would not be suitable, consider 'C' or 'D' alkaline.
A 6v sealed lead acid [SLA] batteries, rated at 2A-hr or higher would be a better option, they are easily recharged with a simple charger and would IMO be more cost effective compared to replacing 'C' or 'D' type batteries.

When using a 6V SLA, the voltage will decrease down to approx 5.4v, then it will require a recharge.
[The alkaline batteries could decrease to 4.4v or less, so a regulated 5v would not be maintained]

Consider driving the MCU and logic circuits, using a low drop out reg [LDO] and the motor directly from the battery/s.
You calculate approx 200mA for the MCU etc, so a low power reg, say 500mA rated, would be OK.

There are other battery technologies you could consider , Li-Ion.

E
I'll go with the Sealed Lead Acid Battery.

By the way, are there any alternatives to FDS6685? I want to use through hole parts.

Also, the voltage regulator should set the voltage to 5V, correct?
 

ericgibbs

Joined Jan 29, 2010
21,448
hi,
This image is one option.
I will look for a thru hole type.

EDIT:
Thru hole.
FQP7P06 1st Choice
IRF9520
IRF4905
If you cannot get these, let me know what types are available
 

Attachments

Last edited:

Thread Starter

elec_system_design

Joined Jun 23, 2017
49
hi,
This image is one option.
I will look for a thru hole type.

EDIT:
Thru hole.
FQP7P06 1st Choice
IRF9520
IRF4905
If you cannot get these, let me know what types are available
I can get any of these parts, but FQP7P06 is the most expensive.

Would going for IRF9520 or IRF4905 make much of a difference?

Edit: Also, would the LM2940 be your first choice for the voltage regulator?
 
Last edited:
Top