Found the issue - unplugging the PICKit and the speed increase at which it works is dramatic - I changed to using 32MHz internal - and running happily at 100kHz (with mods as per previous post)
Martin
Search found 1651 matches
- Tue Feb 03, 2026 9:56 pm
- Forum: General
- Topic: 16f18877 internal Zero Cross Detector
- Replies: 6
- Views: 242
- Tue Feb 03, 2026 6:50 pm
- Forum: General
- Topic: 16f18877 internal Zero Cross Detector
- Replies: 6
- Views: 242
Re: 16f18877 internal Zero Cross Detector
Sounds an interesting project - let us know how it goes.
I just tested changing the ISR to just toggle the state of 'on' - and in the main loop have pin = on - still reflects the right time period, but still doesn't gp above 5kHz
Martin
I just tested changing the ISR to just toggle the state of 'on' - and in the main loop have pin = on - still reflects the right time period, but still doesn't gp above 5kHz
Martin
- Mon Feb 02, 2026 9:40 pm
- Forum: General
- Topic: 16f18877 internal Zero Cross Detector
- Replies: 6
- Views: 242
Re: 16f18877 internal Zero Cross Detector
Something to try: The ZCD should be capable of much higher speeds than this (although maybe not toggling a pin - which will take quite a few cycles) - try incrementing a counter in the ISR instead of the pin set - then output the count every 1s to a UART (via a FTDI convertor) or a display. A capaci...
- Mon Feb 02, 2026 9:24 pm
- Forum: General
- Topic: 16f18877 internal Zero Cross Detector
- Replies: 6
- Views: 242
Re: 16f18877 internal Zero Cross Detector
I wired up a PIC16F18877 to a signal generator and tried the ZCD hardware. Note - I tested with a 20MHz external crystal - if you have use the internal oscillator at 32MHz you will need to set OSCCON. (I did a blinkie first to test settings correct!) This very small sample code - I enable the ZCD in...
- Mon Feb 02, 2026 6:54 am
- Forum: General
- Topic: 16f18877 internal Zero Cross Detector
- Replies: 6
- Views: 242
Re: 16f18877 internal Zero Cross Detector
Yes, you would need to use some C to enable the ZCD module - this would be in either a code block or in a custom interrupt. See section 21 of the datasheet. It looks relatively straightforward - but if using it to measure mains zero crossing then great care is needed with the wiring (not something f...
- Fri Jan 30, 2026 10:33 pm
- Forum: Projects - Embedded
- Topic: Variable length buffer with variable size data.
- Replies: 0
- Views: 112
Variable length buffer with variable size data.
An idea... A data buffer to hold (up to) a fixed number of samples - but the number of samples and the size of the sample (byte, int, or long) - can be decided at run time - not at compile time. This allows a user selectable range - with more elements stored if using a smaller data size (byte (size ...
- Wed Jan 28, 2026 10:21 pm
- Forum: General
- Topic: Rolling average - circular buffer questions
- Replies: 9
- Views: 689
Re: Rolling average - circular buffer questions
It does 'destroy' the data if you use GetValue. So if you need the last 5 values then GetIndexValue doesn't work - it does what you say - it writes to the end of the array and then starts again at the beginning. It would be possible to create a circular buffer that has the behaviour you require (pos...
- Wed Jan 28, 2026 9:51 pm
- Forum: General
- Topic: Rolling average - circular buffer questions
- Replies: 9
- Views: 689
Re: Rolling average - circular buffer questions
If using the circular buffer - then if you don't mind destroying the contents of the buffer - then it's possible - it returns the earliest samples first (so - if you want the last 10 - then discard until 10 (or 10 minutes worth) remain - then average) If you need to keep all the values (user chooses...
- Wed Jan 28, 2026 1:50 pm
- Forum: General
- Topic: Implementing a non blocking delay
- Replies: 74
- Views: 6461
Re: Implementing a non blocking delay
Demo runs rather better if exported as a Flowcode app....
Martin
Martin
- Wed Jan 28, 2026 11:43 am
- Forum: General
- Topic: Implementing a non blocking delay
- Replies: 74
- Views: 6461
Re: Implementing a non blocking delay
I did a simulation only version of the 'slots' approach.... The only v11 (maybe) thing is LED::SetState() - Can replace with If(value) LedOn else LedOff. As it's simulation only - memory not an issue :-) In my crude 'conveyor belt' animation it takes an item about 30s to get from 'button' to 'reject...