Jump to content
  • 0

Set Digital Output pulse at 1V8 using SDK


Bruno

Question

Hello, I have an Analog Discovery 2 board and I would like to perform a digital output pulse at 1V8 (pulse duration of 1.1ms).

I have to create an interruption in my I2S Clock and what it has been done previously was that to create a pulse with the digital output 0. But the problem is that it doesn't work all the time when I launch their script.

When I do it manually with the WaveForm Software 3.15.2 it works only if I set the Digital Input to 1V8 ("Settings->Device manager" tab).
In the picture attached you can see 2 Digital Input 1V8 and both configuration work.
Then I proceed to Switch->Push/Pull and when the value goes to 1, the I2S clock stops immediately (which is what I want).

Can I find an API to do it in the SDK? I mean... I can do it on the WaveForm...


Best Regards,

AD2_Digilent.PNG

Edited by Bruno
Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0

Hi @attila

 

Thank you for your message. I tried to do something similar but when you do this

# set 1.8V digital IO voltage for devices which support
dwf.FDwfDeviceParamSet(hdwf, DwfParamDigitalVoltage, 1800) # mV

VSCode tells me that "DwfParamDigitalVoltage" is not defined. Which is an error that I had. How can I download the latest SDK please?

 

 

Best Regards

Link to comment
Share on other sites

  • 0

Hi @attila

I have downloaded the new software and installed everything, now "DwfParamDigitalVoltage" is recognized. Thank you !

Though, when I run your program I measure 3.3 Volts with my Logic Analyzer each time it sends a pulse. I don't know why it doesn't send a 1.8 V pulse...

When I try to do it manually through WaveForms, like written in my first post, I measure as well 3.3 V. So I cannot even do it manually...

What should I do?

 

Best Regards,

AD2_Digilent_Voltage_3.3.PNG

Link to comment
Share on other sites

  • 0

Hi @Bruno

I though you are using Digital Discovery. Only this and ADP3X50 support DIO voltage adjustment.
The Analog Discovery 1, 2, 3 have fixed 3.3V DIO voltage. You could use voltage level shifter or divider. You could modify the script to drive 0/1 if you need so, since currently uses Z and 0 or 1.

Link to comment
Share on other sites

  • 0

Hi @attila

I manage to get a Digital Discovery (I guess it's the DD1).

When I launch your code DigitalOut_Pulse2.py without doing anything I get noise picked up by the digital channel (see D15 Channel 15).
Also, I get a Vrms value at 700mV instead of the 1V8 written in the code.

Do you happen to know why?

DD_Digilent_NOISE.PNG

Link to comment
Share on other sites

  • 0

The same phenomena happens when I launch DigitalOut_Pulse.py

But if I launch DigitalOut_Pins.py I get a nice clean signal at 1V2 and then no noise anymore.

(In the image you see DigitalOut_Pulse.py followed by DigitalOut_Pins.py)

DD_Digilent_NOISE_PINS.PNG

Link to comment
Share on other sites

  • 0
Posted (edited)

Hi @attila

I manage to create a pulse at 1V8 during 1.1 ms using the Digital Discovery.
I have 1 question that remains :

How can I ouput 5V with the DD? In the Reference manual it's says that it's possible at least to read 5V signals. (Shall I use VIO? how can I address to that PIN ?) For this issue this is what I tried

"""
   DWF Python Example
   Author:  Digilent, Inc.
   Revision:  2020-04-07

   Requires:                       
       Python 2.7, 3
"""

from ctypes import *
from dwfconstants import *
import math
import time
import sys

if sys.platform.startswith("win"):
    dwf = cdll.dwf
elif sys.platform.startswith("darwin"):
    dwf = cdll.LoadLibrary("/Library/Frameworks/dwf.framework/dwf")
else:
    dwf = cdll.LoadLibrary("libdwf.so")

version = create_string_buffer(16)
dwf.FDwfGetVersion(version)
print("DWF Version: "+str(version.value))

print("Opening first device")
hdwf = c_int()
dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf))

if hdwf.value == 0:
    print("failed to open device")
    szerr = create_string_buffer(512)
    dwf.FDwfGetLastErrorMsg(szerr)
    print(str(szerr.value))
    quit()

# the device will only be configured when FDwf###Configure is called
dwf.FDwfDeviceAutoConfigureSet(hdwf, c_int(0)) 


hzSys = c_double()
dwf.FDwfDigitalOutInternalClockInfo(hdwf, byref(hzSys))

# 1kHz pulse on IO pin 25
dwf.FDwfDigitalOutEnableSet(hdwf, c_int(1), c_int(1)) #GPIO 1 to get PIN 25
# prescaler to 2kHz, SystemFrequency/1kHz/2
#dwf.FDwfDigitalOutDividerSet(hdwf, c_int(0), c_int(int(hzSys.value/1e3/2)))
# 0 tick low, 1 tick high
dwf.FDwfDigitalOutCounterSet(hdwf, c_int(1), c_int(0), c_int(1))

# set 5V digital IO voltage for devices which support 
dwf.FDwfDeviceParamSet(hdwf, DwfParamDigitalVoltage, 5000) # mV

dwf.FDwfDigitalOutConfigure(hdwf, c_int(1))

print("Generating output for 10 seconds...")
time.sleep(10)

dwf.FDwfDigitalOutReset(hdwf)
dwf.FDwfDeviceCloseAll()

 

Unfortunately, I only have a 3V2 output and not a 5V output.


Source : https://digilent.com/reference/test-and-measurement/digital-discovery/reference-manual

Section 9.2. Multi-purpose Digital I/O
 

Edited by Bruno
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...