Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 01:52 05 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : read out carolling christmas bells

     Page 2 of 2    
Author Message
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 966
Posted: 08:02pm 03 Nov 2025
Copy link to clipboard 
Print this post

@Volhout:

Thanks for your link - the project looks very interesting too.


@phill99:

Thanks! Now I just have to solder the voltage dividers together. Let's see if I can get around to it this week...



I just unscrewed the electronics again. A proprietary µC with 2x ULN2003 was installed. I bought it in 1994...
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2802
Posted: 05:54am 04 Nov 2025
Copy link to clipboard 
Print this post

A rudimentary test setup with two PicoMites. The first is a simulated xylophone player with a Sub to make a random sequence of notes. The second Pico records the output of the first. GP0 - GP11 connect to GP0 - GP11 on the other, plus Gnd.

The Player and it's output.
'Xylophone player
Dim float SPD=50 'solenoid pulse duration
Dim integer n, Bell.note
Dim float Bell.time, interval

MakeFile 'Sub to create a test file

For n=0 To 11
 SetPin MM.Info(pinno "GP"+Str$(n)),DOUT
Next

Open "BellSample.dat" For Input As #1

Print "Input time","Solenoid(s)",,"Output time", "interval"

Timer = 0

For n=0 To 20
 Input #1, Bell.time, Bell.note 'get the data
 Do While Timer < Bell.time : Loop 'wait for next note
 Port(1,2,4,4,9,4,14,2) = Bell.note 'ring the bells
 Print Bell.time, Bin$(Bell.note,12),, Timer, Bell.time-interval
 Pause SPD 'solenoid pulse duration
 Port(1,2,4,4,9,4,14,2) = 0 'all solenoids off
 interval = Bell.time
Next

Sub MakeFile
 Open "BellSample.dat" For Output As #1
 For n=0 To 20
 Inc Bell.time, (Rnd * 400 + 100) 'random intervals from 100 to 500mS
 Bell.note = (1 << Fix(Rnd * 12)) Or (1 << Fix(Rnd * 12)) ' ring 2 random bells
 Print #1, Bell.time;","; Bell.note
 Print Bell.time, Bin$(Bell.note,12)
 Next
 Print :Print
 Close #1
End Sub

End
> list "BellSample.dat"
481.4629415, 2052
685.9638557, 1088
1068.890898, 8
1426.471311, 1280
1703.731011, 513
2041.607806, 10
2521.895152, 2176
2973.670426, 272
3319.063016, 1026
3594.936921, 12
3897.402463, 320
4246.852904, 65
4572.434282, 66
4912.247204, 24
5308.362597, 2056
5558.917196, 96
6047.464737, 144
6296.664923, 17
6690.30336, 128
7141.14529, 9
7640.742658, 576
>
> RUN
Input time      Solenoid(s)             Output time     interval
481.4629415    100000000100             482.564         481.4629415
685.9638557    010001000000             686.728         204.5009142
1068.890898    000000001000             1069.802        382.9270423
1426.471311    010100000000             1427.26         357.580413
1703.731011    001000000001             1704.547        277.2597
2041.607806    000000001010             2042.513        337.876795
2521.895152    100010000000             2522.739        480.287346
2973.670426    000100010000             2974.523        451.775274
3319.063016    010000000010             3319.816        345.39259
3594.936921    000000001100             3595.753        275.873905
3897.402463    000101000000             3898.184        302.465542
4246.852904    000001000001             4247.658        349.450441
4572.434282    000001000010             4573.378        325.581378
4912.247204    000000011000             4912.997        339.812922
5308.362597    100000001000             5309.247        396.115393
5558.917196    000001100000             5559.793        250.554599
6047.464737    000010010000             6048.339        488.547541
6296.664923    000000010001             6297.477        249.200186
6690.30336     000010000000             6691.216        393.638437
7141.14529     000000001001             7141.996        450.84193
7640.742658    001001000000             7641.568        499.597368
>

And the recorder.
'Reading the 12 outputs of a chiming bells ornament. (untested)
'It records the time (mS) when each bell is struck and the number of the bell(s)

Dim integer n, tmr

For n=0 To 11
SetPin MM.Info(pinno "GP"+Str$(n)),DIN
Next

Open "RecordBells.dat" For Output As #1
Print "Timer", "Solenoid", "Interval mS"

Do : Loop Until Port(gp0,12) 'wait for the first pulse
Timer = 0

For n = 0 To 20 'or whatever the sequence length is
 tmr = Timer
 Do : Loop Until Port(gp0,12) 'wait for a chime
 Print #1, Timer; ",", Port(gp0,12)
 Print Timer; ",", Bin$(Port(gp0,12),12),
 Pause 59 'Wait for solenoid pulse to end.
'longer than a solenoid pulse, shorter than the shortest interval between chimes
 Print Timer-tmr
Next

End
>
Timer   Solenoid        Interval mS
0.63   100000000100     60.155
204.649        010001000000     204.037
587.569        000000001000     382.963
945.156        010100000000     357.554
1222.416       001000000001     276.773
1560.298       000000001010     337.668
2040.59        100010000000     479.964
2492.343       000100010000     451.745
2837.741       010000000010     345.127
3113.62        000000001100     276.019
3416.073       000101000000     302.458
3765.537       000001000001     348.913
4091.158       000001000010     325.534
4430.916       000000011000     339.332
4827.065       100000001000     395.442
5108.852       000001100000     281.836
5566.197       000010010000     456.61
5815.364       000000010001     248.781
6209.013       000010000000     393.396
6659.849       000000001001     450.249
7159.442       001001000000     498.807
>
> list "RecordBells.dat"
0.31,   2052
204.47,     1088
587.42,     8
944.987,    1280
1222.252,   513
1560.135,   10
2040.435,   2176
2492.191,   272
2837.587,   1026
3113.471,   12
3415.919,   320
3765.39,    65
4090.978,   66
4430.765,   24
4826.909,   2056
5077.469,   96
5566.021,   144
5815.193,   17
6208.862,   128
6659.704,   9
7159.296,   576
>

It's been a wet day so stuck indoors.
Edited 2025-11-04 16:01 by phil99

Footnote added 2025-11-04 21:28 by phil99
In the first program (Xylophone player) the Port command can be simplified to  Port(gp0,12) from Port(1,2, 4,4, 9,4, 14,2)
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5417
Posted: 06:11am 04 Nov 2025
Copy link to clipboard 
Print this post

PORT(GP0,12) ?

Volhout
PicomiteVGA PETSCII ROBOTS
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2802
Posted: 06:27am 04 Nov 2025
Copy link to clipboard 
Print this post

Yes, the Port Function behaves differently to the Port Command. It works so I wont complain!
 
     Page 2 of 2    
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025