Exploring an idea for a neuroscience application.
2 channel constant current programmable output, IR communications, weight < 3 grams
To make the experience fit your profile, pick a username and tell us what interests you.
We found and based on your interests.
Exploring an idea for a neuroscience application.
mouse hat large4.brdbrd - 65.88 kB - 10/14/2020 at 13:05 |
|
|
mouse hat large4.schsch - 160.69 kB - 10/14/2020 at 13:05 |
|
|
lecroy-wavesurfer-3054-4-channel-oscilloscope-digital-storage-oscilloscope-wavesurfer-3054-user-manual.pdfAdobe Portable Document Format - 11.60 MB - 06/19/2020 at 15:54 |
|
|
CR1025.pdfAdobe Portable Document Format - 960.99 kB - 06/19/2020 at 15:54 |
|
|
current-output-circuit-techniques-add-versatility.pdfAdobe Portable Document Format - 109.48 kB - 06/19/2020 at 15:54 |
|
|
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.
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.
Todo:
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.
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.
Then:
To do: work out IR receiver circuit to adjust current and pulse output.
I used this guide and the TSOP62 datasheet to come up with a simple test circuit.
The input comes from a transmitter.
Today's tasks:
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.
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.
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.
The specs of this project are:
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.
Create an account to leave a comment. Already have an account? Log In.
Become a member to follow this project and never miss any updates
By using our website and services, you expressly agree to the placement of our performance, functionality, and advertising cookies. Learn More