06/06/2020 at 21:19 •
05/20/2020 at 01:33 •
The signals image in the last log shows an interrupt on every rising edge, and so whatever I thought I coded wasn't it.
This image is perfect. The pink signal on the top is the interrupt being triggered every time the IR receiver gets a hit. It's inverse, but it's not a big deal.
Now I need to count the time in between the pulses.
05/17/2020 at 15:57 •
I've been working on NEC decoding for a few weekends now, and I'm starting to understand it, although coding in C is tricky for me.
The basic premise is that an interrupt on rising/ falling edge change starts a timer and this is checked against the NEC condition.
I'm using this page by Simple Projects as a guide.
The message of the NEC protocol is 32-bit long, address (16 bits), command (8 bits), and inverted command (8 bits). Before the 32 bits there is 9ms burst and 4.5ms space.
A logic 1 is represented by 562.5µs burst and 562.5µs space (total of 1125µs) and a logic 0 is represented by 562.5µs burst and 1687.5µs space (total of 2250µs).
In my PIC16LF1708, I've got the external interrupt connected to pin A2 (input from IR receiver) on falling edge working with Timer0.
- Make the external interrupt on A2 interrupt on change.
- Figure out what the numbers in the TMR0 register equate to, and if a different timer is needed.
TMR0 is 8 bits, so counts to 256 in 65ms (using INTOSC, 4MHz). Since the total length of a 1,2,3,4,5, or 6 on the NEC remote I have is about 56ms, it's fine for the moment. Might move to Timer1 later.
I'm having a lot of trouble getting the IOC (interrupt on change) to work. I've tried a few examples and they're simple enough, but the IOC happens intermittently. I'm thinking about soldering a debounce circuit onto my Curiosity board to filter out garbage signals.
In the image below, the top signal is the interrupt, the bottom signal is pressing the "2" key on the remote control. I don't think it's a good enough match to decode.
04/26/2020 at 17:42 •
Today's goal is to measure the time between external interrupts.
External INT on a PIC16LF1708 is on RA2. Use the internal weak pull-up.
It's not that easy to find where to set, so I'll put it here. Use MCC's Pin Module to enable the register. In order to set individual pull-ups (rather than a whole port at once), the WPUEN bit must be enabled.
- Go to ISR
- Set Timer0 to 0
- Count until next EXT interrupt // here I am using a wire on A2
- Timer0 = elapsedTime
- elapsedTime - 0 = time
- Timer0 = 0
- 04/12/2020 at 15:54 • 0 comments
03/29/2020 at 21:37 •
- Configure DAC: make sawtooth wave
- Configure op Amp as c2v converter
- Choose GPIO and output 100 Hz and 158 Hz square waves
- Start designing IR receiver circuit
Configuring the DAC wasn't hard, but with the Curiosity board there's a gotcha. Pin RA0 (DAC1 output) has some kind of load (edit: an LED is attached) on it. The DAC is simply ramping up/down using the DAC1CON1 register. With several tries I only reached 2.0 volts at peak (you can see in column B).
Eventually I pulled just that pin out of the socket and this is the nice signal, exactly as expected.
03/22/2020 at 22:05 •
I started the work sesh with these main tasks:
1. Configure both the DAC and the op-amp in MPLAB. This checks out, there is 1.005V on pin 17 (DACOUT2)
2. Configure the Curiosity board to measure current. I added a 22k resistor across pins 13 to GND, and a red LED between pins 13 and 14. POT1 on the curiosity board ramps the DAC input up and down.
3. Write firmware to ramp the DAC input up and down.
I'm not sure if/ how to do an input to the DAC internally (right now I'm using an external pot). I'm also unsure if it's even possible to have multiple digital levels.
I *think* so as it says in the data sheet: The DAC has 256 voltage level ranges. The 256 levels are set with the DAC1R<7:0> bits of the DAC1CON1 register.
03/01/2020 at 23:16 •
The PICLF1703 (and 1717 etc.) have integrated OpAmps.
I'm configuring one of them as a voltage to current converter (transconductance amplifier) using Microchip's graphical MPLAB X IDE w Code Configurator. It looks like this:
Note: A device reset forces all registers to their reset state. This disables the OPA module.
Ok excuse this crappy sketch, it's a placeholder so I don't forget where I was. I wired this up. R1 = 100 ohm and R2 is 22k. Nothing happened when I downloaded the config into the chip, will troubleshoot soon.
02/21/2020 at 19:02 •
The specs of this project are:
- 1 input channel: IR 38kHz receiver
- 2 output channels
- 2 different frequency pulses in the 130 Hz range
- Programmable constant current on output in 30 - 250 uA range
- LED to show pulsing (2 different patterns or colors)
- LED to show power on
- IR transmitter (off-the-shelf) compatible with 38kHz receiver
- Coin cell battery CR1025 (10 mm dia)
- Desired weight < 2.5 grams
- Desired area footprint 1 cm x 1 cm
I'm prototyping with one of Microchip's Curiosity dev board, which comes with a 20 pin DIP PIC16F1619.
I've gotten to blinky with MP Lab X and the code configurator, the documentation isn't that great, but maybe just because there's a lot of it. Getting to blinky took 2 hours.
I swapped the 20 pin DIP out for a 14 pin DIP PIC16LF1703. This chip has 2 on-chip opAmps. I need a constant current supply for the circuit I'm designing, and so thought it might work with one of the on-chip opAmps.