Search found 1649 matches
- Mon Feb 02, 2026 9:40 pm
- Forum: General
- Topic: 16f18877 internal Zero Cross Detector
- Replies: 4
- Views: 133
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: 4
- Views: 133
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: 4
- Views: 133
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: 81
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: 545
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: 545
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: 6039
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: 6039
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...
- Wed Jan 28, 2026 7:05 am
- Forum: General
- Topic: Implementing a non blocking delay
- Replies: 74
- Views: 6039
Re: Implementing a non blocking delay
A couple of other ideas.... To handle the multiple 'item' issue. Both in 'idea' form... Represent the conveyor as a series of slots - where 0 is okay and one is 'faulty' - this could be a circular buffer (or an array of bytes / bits) - this needs to 'move' in sync with the conveyor. When a high puls...
- Tue Jan 27, 2026 10:01 pm
- Forum: General
- Topic: Rolling average - circular buffer questions
- Replies: 9
- Views: 545
Re: Rolling average - circular buffer questions
Should be able to do what you want it to.. If you set to save the last '5' values (as an example - I know you will need more) So it will always contain 5 values (after at least 5 have been read) - and adding new will overwrite the earliest data. However - get indexed value returns the value at the i...