SignalGenerator

Tested SignalGenerator from example

https://docs.ghielectronics.com/software/tinyclr/tutorials/signal-control.html#signal-generator

and used different values (but seems values are not correct)

if i used TimeSpan.FromTicks(10) - this supposed to be 1 uS (microsecond)

after mesasuring i’ve got those close results

          var buffer = new[] {
    TimeSpan.FromTicks(10), //01 1.25 uS
    TimeSpan.FromTicks(10), //02 1.25 uS
    TimeSpan.FromTicks(10), //03 1.18 uS
    TimeSpan.FromTicks(10), //04 1.31 uS

    TimeSpan.FromTicks(8), //05 1.00 uS
    TimeSpan.FromTicks(8), //06 1.00 uS
    TimeSpan.FromTicks(8), //07 1.06 uS
    TimeSpan.FromTicks(8), //08 1.00 uS

    TimeSpan.FromTicks(7), //09 0.93 uS
    TimeSpan.FromTicks(7), //10 0.93 uS
    TimeSpan.FromTicks(7), //11 0.93 uS
    TimeSpan.FromTicks(7), //12 1.06 uS

    TimeSpan.FromTicks(5), //13 0.62 uS
    TimeSpan.FromTicks(5), //14 0.81 uS
    TimeSpan.FromTicks(5), //15 0.62 uS
    TimeSpan.FromTicks(5), //16 0.62 uS 
};

if i used TimeSpan.FromSeconds(0.01) - this supposed to be 10 ms (millisecond)




    TimeSpan.FromSeconds(0.01),
    TimeSpan.FromSeconds(0.01),
    TimeSpan.FromSeconds(0.01),
    TimeSpan.FromSeconds(0.01),
    TimeSpan.FromSeconds(0.01),
    TimeSpan.FromSeconds(0.01),
    TimeSpan.FromSeconds(0.01),
    TimeSpan.FromSeconds(0.01),

var signalPin = GHIElectronics.TinyCLR.Devices.Gpio.GpioController.GetDefault().OpenPin(GHIElectronics.TinyCLR.Pins.SC20100.GpioPin.PE4);
signalPin.SetDriveMode(GpioPinDriveMode.Output);

        int cnt = 0; ;

        while (cnt<=1000)
        {
            signalPin.Write(GpioPinValue.High);
            Thread.Sleep(10);
            signalPin.Write(GpioPinValue.Low);
            Thread.Sleep(10);

            cnt++;
        }

is more accurate

This is done on software so it has let limits. 1us is too small

but what about 10 ms (millisecond) accurate …

  • second picture show differences between 8.0 , 8.97 , 8.7, 9.0 , 10.10 (is close to),10.10 (is close to),8.22 …

we need at least to make sure for precise milliSeconds if not at uS (microseconds)

  • and the best is third pictures pure on/off …

TinyCLR? Not real time. PWM might be better since it is hardware?

Not real time, that’s true. And microsecond accuracy is more than a dream. PWM could indeed help for accurate timings but you would then loose the ease of use of a tab of durations in the case of a signal generator.

But at millisecond level, why are both software versions not equally accurate with such big differences ? I think @valon_hoti_gmail_com could “accept” 0.1ms or 0.2ms differences, but not 1ms or 2ms.

1 Like

Disable interrupt = true will more accurate.

Neopixel is 400ns and 800ns work so ms should be fine.

2 Likes

thanx @Dat_Tran ,
at uS remain the same but at millisecods now it was very accurate with Disable interrupt = true

3 Likes

with PWM now i need to create formula to be able to generate any signal generator

generated 315 nanosecond = 62.5 nS {0} + 250 ns {1} signal