Author Topic: Converting a two level analog signal to two bits digital in Cyclone IV or/and V  (Read 5680 times)

0 Members and 1 Guest are viewing this topic.

Offline MitiTopic starter

  • Super Contributor
  • ***
  • Posts: 1355
  • Country: ca
I'm looking to convert a two level analog signal into a two bits digital using only the input features of the Cyclone 4 (and I don't thing Cyclone 5 is that much different). I see it can be done in Xilinx Spartan 6, I'm looking at the NewScope-0Jr Operating Manual from Simmconn Labs, board shot attached.
Looking at the "Cyclone IV Device Datasheet" I can't find an easy way to achieve this. I was hoping that I can find a voltage referenced or differential standard that I can play with the Vref or negative input but looks like the requirements are pretty tight and I cannot deviate too much from the VCCIO/2 either with Vref or VCM.
Is Xilinx so much more versatile from this point of view than Altera or am I missing something? Which wouldn't surprise me.

Thanks!
« Last Edit: July 12, 2020, 05:33:54 pm by Miti »
Fear does not stop death, it stops life.
 
The following users thanked this post: vmax

Online BrianHG

  • Super Contributor
  • ***
  • Posts: 8086
  • Country: ca
Not enough analog details.  For all I know from your scope shot, 2 NPN transistors, 4 correct resistors will suffice, though the data out will be inverted and you would have to do a thermal range sweep.  A dual comparator or 2 single ones in SOT23-5 package would do the same with better temp immunity if you use your VCCA from the FPGA for your resistor divider feeding your reference.  Again you would need 3 correct resistor values.  2 more if the comparator you choose needs pullups on the outputs.

If your source is an analog signal, I would not trust driving any FPGAs IOs directly.  Though with a series resistor like 10k, the input diode protection on most IO pins are sufficient, but, I would still use schottky protection diodes.

There is a warning in Intel's data sheets about 1 or 2 configuration PS/JTAG IO pins which do not have protection.  The rest should have them.
« Last Edit: July 12, 2020, 06:32:56 pm by BrianHG »
 

Online NiHaoMike

  • Super Contributor
  • ***
  • Posts: 9205
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
There's a hack to use the differential input features of a FPGA as an ADC. Should be able to distinguish between 3 levels pretty easily.

BTW, such strange waveforms often occur during bus collisions as a voltage divider is unintentionally formed by the two drivers, probably would be a good idea to make sure the system has current limiting resistors to prevent damage.
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline langwadt

  • Super Contributor
  • ***
  • Posts: 4701
  • Country: dk
Not enough analog details.  For all I know from your scope shot, 2 NPN transistors, 4 correct resistors will suffice, though the data out will be inverted and you would have to do a thermal range sweep.  A dual comparator or 2 single ones in SOT23-5 package would do the same with better temp immunity if you use your VCCA from the FPGA for your resistor divider feeding your reference.  Again you would need 3 correct resistor values.  2 more if the comparator you choose needs pullups on the outputs.

If your source is an analog signal, I would not trust driving any FPGAs IOs directly.  Though with a series resistor like 10k, the input diode protection on most IO pins are sufficient, but, I would still use schottky protection diodes.

There is a warning in Intel's data sheets about 1 or 2 configuration PS/JTAG IO pins which do not have protection.  The rest should have them.

LVDS inputs are usually pretty good comparators. I  don't know about Intel but Xilinx usually specs 20mA into the protection diodes



 

Offline MitiTopic starter

  • Super Contributor
  • ***
  • Posts: 1355
  • Country: ca
Not enough analog details.  For all I know from your scope shot, 2 NPN transistors, 4 correct resistors will suffice, though the data out will be inverted and you would have to do a thermal range sweep.  A dual comparator or 2 single ones in SOT23-5 package would do the same with better temp immunity if you use your VCCA from the FPGA for your resistor divider feeding your reference.  Again you would need 3 correct resistor values.  2 more if the comparator you choose needs pullups on the outputs.

Thanks Brian! I know I can do it with external components but I was intrigued by how easy was done on the board that I mentioned.
It is the internal video output of an HP8591E spectrum analyzer that goes to the CRT display. It has low intensity for the grid and menus and higher intensity for the trace.

If your source is an analog signal, I would not trust driving any FPGAs IOs directly.  Though with a series resistor like 10k, the input diode protection on most IO pins are sufficient, but, I would still use schottky protection diodes.

If I read correctly in the Cyclone 4 datasheet in the "Table 1–3. Recommended Operating Conditions for Cyclone IV E Devices", the maximum input voltage is 3.6V so doesn't that mean that the IOs are all 3.6V tolerant, regardless of the IO standard selected or Vccio?
« Last Edit: July 12, 2020, 07:59:53 pm by Miti »
Fear does not stop death, it stops life.
 

Offline MitiTopic starter

  • Super Contributor
  • ***
  • Posts: 1355
  • Country: ca
There's a hack to use the differential input features of a FPGA as an ADC. Should be able to distinguish between 3 levels pretty easily.

BTW, such strange waveforms often occur during bus collisions as a voltage divider is unintentionally formed by the two drivers, probably would be a good idea to make sure the system has current limiting resistors to prevent damage.

Do you have a link about that hack?
Yes, I know it looks that way but it is not. As I mentioned above, it is the internal video output of an HP8591E spectrum analyzer that goes to the CRT display. It has low intensity for the grid and menus and higher intensity for the trace.
« Last Edit: July 12, 2020, 08:00:16 pm by Miti »
Fear does not stop death, it stops life.
 

Offline MitiTopic starter

  • Super Contributor
  • ***
  • Posts: 1355
  • Country: ca
Not enough analog details.  For all I know from your scope shot, 2 NPN transistors, 4 correct resistors will suffice, though the data out will be inverted and you would have to do a thermal range sweep.  A dual comparator or 2 single ones in SOT23-5 package would do the same with better temp immunity if you use your VCCA from the FPGA for your resistor divider feeding your reference.  Again you would need 3 correct resistor values.  2 more if the comparator you choose needs pullups on the outputs.

If your source is an analog signal, I would not trust driving any FPGAs IOs directly.  Though with a series resistor like 10k, the input diode protection on most IO pins are sufficient, but, I would still use schottky protection diodes.

There is a warning in Intel's data sheets about 1 or 2 configuration PS/JTAG IO pins which do not have protection.  The rest should have them.

LVDS inputs are usually pretty good comparators. I  don't know about Intel but Xilinx usually specs 20mA into the protection diodes

They should be but if you look at the datasheet, the common mode is specified pretty tight around the VCCIO/2. I'm not sure how far from that I can push it and it still works or I don't damage the inputs.
Fear does not stop death, it stops life.
 

Offline langwadt

  • Super Contributor
  • ***
  • Posts: 4701
  • Country: dk
Not enough analog details.  For all I know from your scope shot, 2 NPN transistors, 4 correct resistors will suffice, though the data out will be inverted and you would have to do a thermal range sweep.  A dual comparator or 2 single ones in SOT23-5 package would do the same with better temp immunity if you use your VCCA from the FPGA for your resistor divider feeding your reference.  Again you would need 3 correct resistor values.  2 more if the comparator you choose needs pullups on the outputs.

If your source is an analog signal, I would not trust driving any FPGAs IOs directly.  Though with a series resistor like 10k, the input diode protection on most IO pins are sufficient, but, I would still use schottky protection diodes.

There is a warning in Intel's data sheets about 1 or 2 configuration PS/JTAG IO pins which do not have protection.  The rest should have them.

LVDS inputs are usually pretty good comparators. I  don't know about Intel but Xilinx usually specs 20mA into the protection diodes

They should be but if you look at the datasheet, the common mode is specified pretty tight around the VCCIO/2. I'm not sure how far from that I can push it and it still works or I don't damage the inputs.

what are your signal levels?
 

Online BrianHG

  • Super Contributor
  • ***
  • Posts: 8086
  • Country: ca

Thanks Brian! I know I can do it with external components but I was intrigued by how easy was done on the board that I mentioned.
It is the internal video output of an HP8591E spectrum analyzer that goes to the CRT display. It has low intensity for the grid and menus and higher intensity for the trace.


Are you trying to capture a video signal?  You want to derive 2 levels of luminance?
Without clock locking, it will be noisy, but you can still do it.  It would be better getting that clock from the analyzer's video output oscilator.  Also, that 2 level gray is most likely already just 2 TTL outputs going through 2-3 resistors.  Tapping those source outputs and the clock oscillator on the analyzer would give you the capability of dead perfect sampling.

As for getting that 3 level signal into an IO in a determined way, a 3.3v IO bank should be able to capture the low pulse already.  If not, a 2.5v bank IO pin would for certain.

To capture the high contrast signal, the source signal should go through a small signal double silicon or double schottky diode.  This will erase the first 1.3 to 1.5v of the source signal and only let through the remaining 1.5v as 1.5v when high contrast is coming out.  After the diode, you need a pull down resistor and tie that to a second IO.

These options do not use the 'VREF' input pin.  I have never used the feature so I cant comment.

« Last Edit: July 12, 2020, 09:37:07 pm by BrianHG »
 

Offline MitiTopic starter

  • Super Contributor
  • ***
  • Posts: 1355
  • Country: ca
what are your signal levels?

Maximum is 3V for high contrast and 1.5 for low contrast.
Fear does not stop death, it stops life.
 

Offline langwadt

  • Super Contributor
  • ***
  • Posts: 4701
  • Country: dk
what are your signal levels?

Maximum is 3V for high contrast and 1.5 for low contrast.

might get away with just two cmos inputs in a  1.8/2.5V bank, high contrast with a voltage divider

might even work in a 3.3V bank, low contrast with a series resistor and pull-up

 
 

Offline MitiTopic starter

  • Super Contributor
  • ***
  • Posts: 1355
  • Country: ca
Are you trying to capture a video signal?  You want to derive 2 levels of luminance?
Without clock locking, it will be noisy, but you can still do it.  It would be better getting that clock from the analyzer's video output oscilator.  Also, that 2 level gray is most likely already just 2 TTL outputs going through 2-3 resistors.  Tapping those source outputs and the clock oscillator on the analyzer would give you the capability of dead perfect sampling.

I've attached the schematic for that section of the SA. I will capture the HSync, VSync and video, digitize the video and buffer it in a two port RAM, then re-clock it into a VGA output. I found a timing scheme where the video frame rate and the VGA frame rate are in sync and I only need to buffer half the video frame then reuse the buffer. I will regenerate the 21MHz clock from the HSync using ICS9173B-15, I tried and it works very well on the VGA side, a pattern on the VGA monitor is very clean, even though there is a bit of jitter in the regenerated video clock, but I didn't have time to play with the other side, the video capture.
See here https://www.eevblog.com/forum/projects/modern-equivalent-of-74hc4046-pll/msg3057236/#msg3057236

Now, sure I can solder some wires at the inputs of U312, and tap into the 21MHz clock, and be done with it, but first I would like to try the less invasive way of simply connecting my circuit to J8 and have an image on the LCD.
Fear does not stop death, it stops life.
 


Offline MitiTopic starter

  • Super Contributor
  • ***
  • Posts: 1355
  • Country: ca
https://www.eevblog.com/forum/projects/modern-equivalent-of-74hc4046-pll/msg3133760/#msg3133760

So, do you say that you coded the 74HC4046's PC2 into the FPGA, then used its VCO?
Would that be an advantage over using the internal PC2? I think I tried that (74HC4046 at 10.5MHz) and the clock jitter wasn't great but I blamed it on the low frequency of 15KHz. It didn't cross my mind that 50% duty cycle would help since the phase is compared on the edge.
Can you share the R and C values for the VCO and the loop filter for 10.5MHz?
Fear does not stop death, it stops life.
 

Online BrianHG

  • Super Contributor
  • ***
  • Posts: 8086
  • Country: ca
Yes, PC2out needs 50/50 duty cycle on both sources to reliably work at such low frequencies.  And it can work even way down at 1Hz with something like a 10k series resistor out and a 1uf-10uf cap to GND for the VCO in.

I would start with 1k and 1nf - 10nf.  For the cap, (cap should be right at pin 9 and GND) film capacitors offer slightly better performance during the transitions in the source signal as the comparator makes slight pulses, however, this is outside your picture area and it shouldn't affect sampling.  I assume your dividing the output of pin 4 and feeding the 7.5khz into pin 3 while pin 14 will have the 15KHz sync divided by 2 to get your 50/50 7.5KHz reference.

As for sampling, make the FPGA multiply the source signal clk by 10x.  When you take in pixels, you should sample a pixel every 5 clocks with a software selection of which one of those 5 phases to use.  This is how some VGA samplers with built in PLL select which phase to sample the input pixels to get rid of transition edge noise.


The R&C for the 10.5MHz oscillator itself is tuned by setting the VCO in to 1/2 VCC and adjust the C and R so that the output is 10.5 MHz.   Then with the VCO in at GND you want something like 9MHz, and at VCC, something like 12MHz.
You do not want too wide tuning as that amplifies noise from the VCO input pin.  Noise isn't generated here, it's generated above with the PC2 output and it's filter to the VCO input pin.  Plus, power supply noise.

This is why I like the TI CDCE PLL clock.  I run it with the PLL VCCa of the cyclone at 2.5v and tune it with 2 transistors from 2 IOs replicating the charge pump function of PC2out inside the 74HC4046.
« Last Edit: July 13, 2020, 12:08:07 am by BrianHG »
 

Online NiHaoMike

  • Super Contributor
  • ***
  • Posts: 9205
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
Do you have a link about that hack?
Yes, I know it looks that way but it is not. As I mentioned above, it is the internal video output of an HP8591E spectrum analyzer that goes to the CRT display. It has low intensity for the grid and menus and higher intensity for the trace.
https://hackaday.com/2015/09/09/video-fpga-with-no-external-ad/
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline asmi

  • Super Contributor
  • ***
  • Posts: 2794
  • Country: ca
Almost all Xilinx 7 series devices have built-in dual 1MSPS ADC. I can't remember if Antel chips have it as well, but if they do, that would be the best solution. Depending on ADC parameters, you might need a voltage divider - for example 7 series ADC is only rated for up to 1 V in unipolar mode or ±0.5 V in bipolar mode.

Offline langwadt

  • Super Contributor
  • ***
  • Posts: 4701
  • Country: dk
Almost all Xilinx 7 series devices have built-in dual 1MSPS ADC. I can't remember if Antel chips have it as well, but if they do, that would be the best solution. Depending on ADC parameters, you might need a voltage divider - for example 7 series ADC is only rated for up to 1 V in unipolar mode or ±0.5 V in bipolar mode.

how's 1Msps going to work with the ~100ns pulse widths shown the OP?

two cmos inputs and few resistors should be enough to distinguish 0V, 1.5V and 3V 
 

Offline c64

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: au
If you have some free IO pins, you can feed your signal to two separate input pins, with different VCCIO.
For example, to 3.3V bank and 2.5V bank
If both capture 1, it's high brightness, if one is 1 and another is 0 - it's low brightness.
May need some pull-ups or pull-downs to make sure it's never near 1/2 VCC
And protection diodes
 

Online BrianHG

  • Super Contributor
  • ***
  • Posts: 8086
  • Country: ca
Your cleanest separation would be use a 2.7-3.3v powered 74AC04, feed 1 input directly, feed a second input through 1 or 2 series 1N914 small signal silicon diode (mmbd914) with a pull down resistor.  The 2 74AC04D outputs will have an inverted image and they will not damage your FPGA.  I would also feed your syncs through the other spare gates in the 74AC04D as you do not care if that IC dies.  It will also respond in less than 5ns.

Most other solutions here are dependent on a finicky transition point in logic gate input threshold and dividing the source signal until that divided down shrinking threshold changes on the source signal level.  Good for 1 home project board, but I wouldn't rely on making such a project public domain, or sell it to anyone.
 

Online BrianHG

  • Super Contributor
  • ***
  • Posts: 8086
  • Country: ca
If you have some free IO pins, you can feed your signal to two separate input pins, with different VCCIO.
For example, to 3.3V bank and 2.5V bank
If both capture 1, it's high brightness, if one is 1 and another is 0 - it's low brightness.
May need some pull-ups or pull-downs to make sure it's never near 1/2 VCC
And protection diodes
Can't guarantee functionality with Intel FPGAs.  The FPGA data sheet has the same 0.7v-1,7v threshold for 2.5v through 3.3v powered IO banks.  Only 1.8v and below do these figures change.
 
The following users thanked this post: c64

Offline MitiTopic starter

  • Super Contributor
  • ***
  • Posts: 1355
  • Country: ca
I think the title of my post should have been "How did that guy do it?". Considering that he fed the signal to two inputs directly through two zero ohm resistors, I suspect he used differential inputs with the negative side to two different levels, I don't know what's on the bottom side of the board, but I suspect there are two voltage dividers.
Fear does not stop death, it stops life.
 

Online BrianHG

  • Super Contributor
  • ***
  • Posts: 8086
  • Country: ca
I think the title of my post should have been "How did that guy do it?". Considering that he fed the signal to two inputs directly through two zero ohm resistors, I suspect he used differential inputs with the negative side to two different levels, I don't know what's on the bottom side of the board, but I suspect there are two voltage dividers.
Assuming it's done exclusively with divider resistors, I would not personally guarantee such a design over many FPGA & pcbs.

Looking at your 500mv/div scope shots.  I would use 2 npn transistors, a series resistor to transistor #1's base, and 1 diode in series with pulldown resistor, the series resistor after the diode feeding the second transistor's base.  Emitters to GND.  Pullups on the output collectors to your desired VCCIO.  That would create a clean digital signal with around 5-15ns pull-down, around 50ns rise when released.

Powering a 74LVC04 at around 2.0v, feeding 2 inputs like the transistor bases above would do the same thing, but respond much faster than the transistors and provide a definite switch to high and low rail, super fast delay + rise and fall times in the order of a few ns.
« Last Edit: July 17, 2020, 07:29:49 pm by BrianHG »
 

Offline langwadt

  • Super Contributor
  • ***
  • Posts: 4701
  • Country: dk
I think the title of my post should have been "How did that guy do it?". Considering that he fed the signal to two inputs directly through two zero ohm resistors, I suspect he used differential inputs with the negative side to two different levels, I don't know what's on the bottom side of the board, but I suspect there are two voltage dividers.
Assuming it's done exclusively with divider resistors, I would not personally guarantee such a design over many FPGA & pcbs.


why not? looking at the spec for LVDS inputs: Vcom = 0.05-1.8V, Vdif = 100mV

so divide input by 2 to get inside the common mode range, and two dividers to set the thresholds

 
The following users thanked this post: Miti

Offline MitiTopic starter

  • Super Contributor
  • ***
  • Posts: 1355
  • Country: ca
I think the title of my post should have been "How did that guy do it?". Considering that he fed the signal to two inputs directly through two zero ohm resistors, I suspect he used differential inputs with the negative side to two different levels, I don't know what's on the bottom side of the board, but I suspect there are two voltage dividers.
Assuming it's done exclusively with divider resistors, I would not personally guarantee such a design over many FPGA & pcbs.


why not? looking at the spec for LVDS inputs: Vcom = 0.05-1.8V, Vdif = 100mV

so divide input by 2 to get inside the common mode range, and two dividers to set the thresholds

This is what I'm talking about. It seems to work very well in simulation.
Since my development board has all VCCIOs connected to 3.3V, I wonder what happens if I assign 2.5V LVDS pairs but the bank is supplied by 3.3V. Is it going to blow up the chip, or is just the levels are messed up? I'm aware that all the I/Os in that bank must be 2.5V, otherwise Quartus will swear at me...
Rename .txt to .asc to simulate in Ltspice.
« Last Edit: July 18, 2020, 02:57:56 pm by Miti »
Fear does not stop death, it stops life.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf