I apologize if this is a trivial question. This is for a BP v3b communicating via I2C with a DAC. I am using the BP to send values [0;4095] to a 12-bit DAC (0-5V). The communication works fine, but now I need to generate a square wave with 1-bit amplitude, oscillating between (for argument sake) 3856 to 3857, at 1kHz. This is to characterize the noise with an oscilloscope and to ensure that I can resolve 1-bit (~1.2mV) voltage steps. I am familiar with the PWM command, but if I understand correctly, I cannot set the amplitude in it. What I am rather after is …(here 0xc0 is the DAC write address, the other two numbers are the value)
I2C>[0xc0 0x0f 0x10]
I2C>% (1 ms delay)
I2C>[0xc0 0x0f 0x11]
I2C>% (1 ms delay)
I2C>[0xc0 0x0f 0x10]
… etc,perhaps with the text output of acks toggled off (if that can affect the performance).
To the best of my knowledge the PWM on the 24FJ64 does not have any amplitude control. You can configure the full cycle period time and the 0/1 bit period, but the high and low is always going to be ground/5-3.3v. I did a quick look for any uCs (STM32F4?) with this feature, and while I know there’s various forms of pulse shaping for motor controllers I couldn’t immediately find anything like this.
You could make a resistor voltage divider to get a 1 bit 1.2mV supply, but oof. The values are not going to be reasonable, even 0.1% is going to have way too much error, and the speed will be severely impacted.
I’m honestly not sure how to get a reliable 1.2mV incrementing square wave. A uC with a 16 or 32 bit DAC might be one option. There is going to be loss on that DAC front end as well, you’ll need at least 2x and usually 4x resolution to really be able to see the individual steps.
Op amps to set a voltage and then a comparator or opamp with an /enable pin? This is analog magic territory and I’m mostly on the digital side.
Thank you, Ian. Actually, I was not looking for an analog solution, digital is what I am after. I thought about a script that would write two alternating numbers via the BP into my DAC with 1ms delay until interrupted. The time delay does not have to be very accurate b.c. I could get time stamps of acks, if needed and back-correct.