Experiment setup, start on timer turn disc at interval

Thread Starter

bjz

Joined Nov 13, 2017
11
I'm trying to build an experiment setup, but my basic electronics knowledge doesn't allow me to figure out what the best way of doing this. I hope to find some help here to get started.

Goal:
I need to turn a disc (max 15 cm in dia. and a few cm high, made out of acrylic) which is divided in 8 sections every hour to a new section (during 8 hours).
I will have multiple replica's (50) of the setup which all need to start their 8 hour cycle at the same time, the day after setting them up.
It has to run on batteries.

My own thought process so far:

I thought of using a relay module (like this: https://www.amazon.com/5-30V-Module-Display-Trigger-Switch/dp/B07NY2KR3D) where I can set
1. delay time for the first start (max 999 min, problematic... see below)
2. the switch on time where I would set it to the amount of seconds to turn the disc a section further. Of course depending on the motor speed e.d.
3. the amount of switch off time (so 1 hour)
4. number of cycles (8).

The problem is that a delay time of 999 min, or 16 hours is not enough. It will also be complicated setting up the experiments as they will be setup during the day (so at different times) but they should all start at the same time the day after.
I thought of using an external clock timer module to set the time of the first trigger signal, but I haven't found anything like this yet.

Another option would be to use an Arduino, but this seems overkill for something simple like this.

Any suggestions what the best way is of doing this ?
Thanks !
 

LesJones

Joined Jan 8, 2017
4,174
A timer such as this may solve your timing problems. It may not be good enough if the 50 units need to remain synchronised for many months. Rather than timing the movement of the disks it might be better to have 8 notches in the perimeter to operate a micro switch. the motor would stop when the micro switch was aligned with a notch. to trigger a move to the next notch you would just buypass the contacts on the micro switch for a few seconds to drive the disk far enough that micro switch was no longer aligned with the notch. The motor would then continue to rotate the disk until the next notch was reached.
Is this a homework or school project ?

Les
 

KeithWalker

Joined Jul 10, 2017
3,063
Does it have to be battery driven?
If you could use an old style motorized timer switch, you could probably do it with a couple of relays and a microswitch.
 

Thread Starter

bjz

Joined Nov 13, 2017
11
Thanks Les, I like the suggestion of using microswitches, simplifies it a bit. And a clock timer like that could work indeed, I guess I was too focussed on finding an electronic clock module.
It doesn't have to be synchronized for a long time, it will only run for 2 days at a time.

And yes, Keith and Eric, it will have to be driven by batteries as it will be used outside.
The type of batteries doesn't matter much, I was thinking of a couple of rechargeable AA batteries. It will only have to power a small motor. I thought of something like this (https://www.amazon.com/1pc-Plastic-Gear-Motor-3V-6V/dp/B07C67LKLP)
 

LesJones

Joined Jan 8, 2017
4,174
If you only have 2.4 volts available the timer I suggested will not work as it's output relay has a 12 volt coil. It would probably be possible to to modify it to use transistors to do the switching. One extra feature that makes it suitable is that it has up to 16 on/off periods so you could set it to give 8 outputs space by one hour to trigger the movement of the disk. You may have to add a circuit to shorten the output on time which can't be less than one minute if the disk takes less then one minute to nove one step.

Les.
 

Jerry-Hat-Trick

Joined Aug 31, 2022
544
Another option would be to use an Arduino, but this seems overkill for something simple like this.
Actually, I'd argue this is an ideal application for an arduino - the huge advantage is that you can easily change the delay times and other variables. For a 24 hour delay you could use delay(30000); for a thirty second pause within a loop that loops 2,880 times. If you want to time and deduct the seconds to move position, use millis();

I'd use one output line with a resistor into the base of an NPN transistor with the motor connnected between the collector and the positive supply, emitter to ground. Turn this on long enough for the turntable to 'escape' a microswitch which is switched by 8 equally spaced pegs. With the motor also wired through the microswitch it will turn off when a peg strkes it.
 

Jerry-Hat-Trick

Joined Aug 31, 2022
544
2. You need feedback to rotate the correct amount.
Sometimes a picture is the easiest way to explain. This is what I tried to explian in my last post on this thread:
1679141132027.png
The peg (of which you would need eight equally spaced around the circumference) would turn SW1 to the off position. The processor output going high would turn on TR1 thereby turning on the motor even when SW1 is open. The peg then moves past SW1 so it closes, holding the motor on. You only have to turn TR1 on long enough for the peg to move past the switch so that the motor is running through the switch, until the next peg opens it again.

You could maybe use an opto interreupter with eight 'curtains' interrupting it, or magnets and a Hall sensor used in a similar way for a more robust outdoor solution.
 

Thread Starter

bjz

Joined Nov 13, 2017
11
If you only have 2.4 volts available the timer I suggested will not work as it's output relay has a 12 volt coil. It would probably be possible to to modify it to use transistors to do the switching. One extra feature that makes it suitable is that it has up to 16 on/off periods so you could set it to give 8 outputs space by one hour to trigger the movement of the disk. You may have to add a circuit to shorten the output on time which can't be less than one minute if the disk takes less then one minute to nove one step.

Les.
I can of course use more batteries, I figured I'll see what I need once I have the electronics figured out, but I try to aim at a small setup, but also practical as AA batteries are easy to reuse for something else as well.
I'm surprised it's so hard to find a clock timer.

Thanks for your input @Jerry-Hat-Trick.
Apart from thinking it might be overkill to use an Arduino, I also don't have any experience with it, except for soldering it into a circuit once for someone. Maybe it's actually worth figuring it out.
But, it is then not easier to just drive a stepper motor ? (not that I know how ;-)...yet )
 
Thanks for your input @Jerry-Hat-Trick.
Apart from thinking it might be overkill to use an Arduino, I also don't have any experience with it, except for soldering it into a circuit once for someone. Maybe it's actually worth figuring it out.
But, it is then not easier to just drive a stepper motor ? (not that I know how ;-)...yet )
A stepper motor is certainly an option - you'd need an H bridge to drive it (from the arduino), but something like https://www.ebay.co.uk/itm/374348860635 comes with a driver board and at a good price for three pieces. That would work open loop, no feedback and with a 64:1 gear ratio is unlikely to slip if you don't try to drive it too fast. Well worthwhile getting to know the Arduino range of products - once you get the hang of it you'll think of endless things you can do. I drive stepper motors with my own code but you can download libraries which do most of the coding for you.
 

LesJones

Joined Jan 8, 2017
4,174
Sometimes telling us exactly what you are trying to achieve can help. Some one my suggest a different approach. For example why does the disk need to step position for 8 hours and then stop for 16 hours. Could it just carry on stepping for these 16 hours. I thought of this when thinking of suggesting using a battery operated clock with some kind of sensor to detect the minute hand passing the 12:00 position to generate a pulse every hour. With only 2.4 volts available would also rule out using an Arduino. If I was doing your project I would use something like a PIC12LF1840 (Which works down to 1.8 volts) or one of the Atmel ATtiny range. As you have to make 50 of these devices using this approach would have a very low component count. You would need the microproccesor, A logic level Mosfet and a crystal if the internal oscillator was not stable enough for your requirements.

Les.
 

Ya’akov

Joined Jan 27, 2019
9,069
This is a nearly perfect application for an ATTiny85 dev board like the Digispark. It’s accessible for a beginner with lots of online materials for support. It is easy to program and has enough I/O for the job. If any of this was wall clock timing critical an RTC (Real Time Clock) module would be a simple addition.

1679315625436.png
 

BobTPH

Joined Jun 5, 2013
8,812
A stepper motor could be used without feedback, but what drives the stepper motor to do 8 advances an hour apart then rest for 16 hours. A single micro can do all of that, doing it with discrete logic might require 5-10 chips.
 

Thread Starter

bjz

Joined Nov 13, 2017
11
I gave the basic information of what I want to achieve, to keep it short and to the point. But if more information is useful, please tell me. So Les to be clear, the experiment only has to run once during those 8 hours, then it is finished.
As I said later, I was thinking of rechargeable AA batteries, but that was not more than an idea. Probably my use of the word "couple" was interpreted as 2, but I didn't think of that as a non-native English speaker, I guess a bunch would have been better.
If I need 9V I use a 9V battery, as long as I don't have to use a 12V car battery, I want to keep it small ;-)
So the 2.4V is not a requirement.
Indeed, having a low component count is quite nice having to build 50, but at the same time with my limited electronics experience, having a base module to start working with is probably easier.

I like the small devboard, Ya'akov, cheaper and smaller than the basic Arduino, and it doesn't have to do much after all.

And BobTPH, this was my thought process indeed, going the microcontroller way, a stepper motor doesn't need the feedback.
The only problem is that I don't have experience with this, and I don't know if it's easy enough to learn without taking it months.

And the clock part is important to be able to have all discs start turning, the day after setting them up, at the same time (although a tolerance of a few minutes is no problem).
 
Indeed, having a low component count is quite nice having to build 50
This is a nearly perfect application for an ATTiny85 dev board like the Digispark.
I overlooked the fact that you need to make 50 pieces to run at the same time! This suggests that cost of components and complexity is an issue so I'm back to the idea of my post #9 where you could have a motor (like the one you mentioned), a small transistor and a microswitch for each turntable.

The ATTiny85 nice, I favour the Seeeduino XIAO, although the popular Arduino UNO has 13 digital outputs each with the ability to drive 20mA so you could maybe turn on 10 outputs simultaneously each turning on 5 transistors (via resistors) The code for that is really simple. I think those motors draw up to 150mA so most small signal NPN transistors with a gain of at least 100 will do. All these components are really inexpensive
 

Ya’akov

Joined Jan 27, 2019
9,069
I overlooked the fact that you need to make 50 pieces to run at the same time!
At quantity 50, I would just buy a small ATTiny85 programming board and program bare chips to be transferred to a different PCB. I would also use ATTiny Core rather than the Digispark bootloader. It would be a breeze to load up the chips (I would use 8-pin DIP versions, and sockets on the PCBs) and plug them into the boards.

I have done this, and the chip just needs a decoupling cap to be good to go. It also makes the cost much lower not to mention the footprint. (Though I just did…)
 

LesJones

Joined Jan 8, 2017
4,174
I can't think of how the TS will be able to start 50 devices at the same time to sychronise them particularly if they are located miles apart. (This though started when I thought that if they were not too far apart a basic wireless link to a master may be a better solution.) This like many request seems to be a secret project.

Les.
 

Ya’akov

Joined Jan 27, 2019
9,069
I can't think of how the TS will be able to start 50 devices at the same time to sychronise them particularly if they are located miles apart. (This though started when I thought that if they were not too far apart a basic wireless link to a master may be a better solution.) This like many request seems to be a secret project.

Les.
If I had to do this, I would probably use a GPS module to sync an RTC module.
 

LesJones

Joined Jan 8, 2017
4,174
Some thoughts on using ATtiny micro controllers.
I write some code to do what I think the TS requires.
As I had some ATtiny13A s in stock I decided to use one of them.
The internal oscillator is not very accurate but there is a register to fine tune it.
It would be time consuming to this for 50 units so I think it would be better to use crystal contol.
The ATtiny13A does not support a crystal oscillator so using an ATtiny85 would be better as that does support a crystal oscillator. I don't have any ATtiny 85s but I do have some ATtiny2313s (20 pin) devices I could modify the code for. (These support a crystal oscillator and have the advantage of a 16 bit timer/counter module.)
These are the prices of the three ATtiny versions from Farnell. (Not including VAT.)
ATtiny13A £0.93
ATtiny85 £1.99 (An ATtiny25 would probably work these are £1.37)
ATtiny2313 £1.65
The code I have written does the following
Start (Power on.)
Disk is in position 0.
Delay 1 hour.
Output pulse to cause motor to motor to move disk to position 1
Delay 1 hour.
Output pulse to cause motor to motor to move disk to position 2
Delay 1 hour.
Output pulse to cause motor to motor to move disk to position 3
Delay 1 hour.
Output pulse to cause motor to motor to move disk to position 4
Delay 1 hour.
Output pulse to cause motor to motor to move disk to position 5
Delay 1 hour.
Output pulse to cause motor to motor to move disk to position 6
Delay 1 hour.
Output pulse to cause motor to motor to move disk to position 7
Delay 1 hour.
Output pulse to cause motor to motor to move disk to position 0
Delay 16 hours
Jump back to Start.

This is the code for the ATtiny13A
Code:
/*
 * Generate 8 pulses spaced 1 hour. Wait 16 hours then repeat
 *
 *  Created: 30/03/23
 *   Author: Les
 */ 
 ;    using ATTINY13A

 ;
;

;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

; 
;
;**************************************************************************
.nolist
.include    <tn13adef.inc>    ; ATtiny 13a 
.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    Hours        = r23    ;Number of Hours
.def    count_L        = r22    ;Used for time delay


;
;******************************** INTERRUPT VECTORS ***********************
.CSEG
.ORG    $00
        rjmp    reset
        reti
        reti
        rjmp     TC_overflow    ;Timer/Counter Overflow
        reti
        reti
        reti
        reti
        reti
        reti
;
;******************************* RESET *************************************
;    
; Initialise the stack-pointer    
reset:
                ldi    R16,low(RAMEND)
                out    SPL,R16

            
; initialize PORTB 
;    Bit 0    Input    (pin 5)     
;    Bit 1    Input
;    Bit 2    Input    (Pin 7)
;    Bit 3    Output  (Pin 2)   (LED drive 0.5 hZ)
;    Bit 4    Output    (Pin 3)      (Pulse output to motor drive. One pules every hour.)
;    Bit 5    Input

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

                    bclr 7        ;Disable global interrupst.

; Init clock prescaler                    
                    ldi R16,0x80        ;Start of special sequence
                    out    CLKPR, R16        ; 
                    ldi    R16,0x03        ; Value for divide by 8  
                    out    CLKPR, R16        ;
                    NOP
                    NOP
                    NOP
                    NOP
                    NOP

;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
                    ldi Hours,0x00

                    bset 7        ;Enable global interrupst.

                    rjmp New_day    ; main loop


;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:            
                    in R20,PORTB
                    ldi R21,0x08        ;Bits 3 
                    eor R20,R21            ; Toggle bit 3 (Pin 2) (Every second)
                    out PORTB,R20

                    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

                    CPI Minutes, 0x08        ;Test code
                    BRGE No_pulse_T             ;Test code
                    RCALL Pulse                ;Test code
No_pulse_T:                                    ;Test code

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

;Inc_Hr:
                    CPI Hours, 0x08
                    BRGE No_pulse

                    RCALL Pulse

No_pulse:
                    ldi R20,0x18        ;24 decimal

                    inc    Hours            ;Increment hours counter
                    cpse Hours,R20
                    rjmp TC_End
                    CLR Hours

TC_End:
                    RETI


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




;
;                    Main program code
;
New_day:
            nop
            nop
            nop
            nop
            rjmp New_day    ; Just loop waiting for interrupt





;Subroutines.

Pulse: 
                    SBI    PORTB,4            ;set pulse high
                    rcall Delay_100ms
                    rcall Delay_100ms
                    rcall Delay_100ms
                    rcall Delay_100ms
                    rcall Delay_100ms
                    rcall Delay_100ms
                    rcall Delay_100ms
                    rcall Delay_100ms
                    rcall Delay_100ms
                    rcall Delay_100ms
                    rcall Delay_100ms
                    rcall Delay_100ms
                    rcall Delay_100ms
                    rcall Delay_100ms
                    rcall Delay_100ms
                    rcall Delay_100ms
                    rcall Delay_100ms
                    rcall Delay_100ms
                    rcall Delay_100ms
                    rcall Delay_100ms
                    CBI    PORTB,4            ;set pulse low
                    ret.
;
;
;                                ----------------------------------------------
; 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 --------------
;
Les.
 
Top