de     

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
en:projects:ucecho_fpga [2010/10/23 00:03] 84.181.72.152en:projects:ucecho_fpga [2013/01/28 02:29] – Add Python 2.6 Example for UCEcho Host coflynn
Line 1: Line 1:
 ====== ucecho for ZTEX USB FPGA boards ====== ====== ucecho for ZTEX USB FPGA boards ======
  
-The following example runs on [[http://www.ztex.de/usb-fpga-1/index.e.html|ZTEX USB FPGA boards]] and gives an impression of the benefits of the macro approach of the ZTEX EZ-USB SDK.+The following example runs on [[http://www.ztex.de/usb-fpga-1/|ZTEX USB FPGA boards]] and gives an impression about the usage of the ZTEX EZ-USB SDK.
  
-The firmware (defined in [[en:projects:usb_fpga-1.2_ucecho#firmwareucechoc|ucecho.c]]) declares Endpoint 2 and Endpoint 4 (both 512 bytes, double buffered, bulk transfer, belong to interface 0). All data that is written to Endpoint 4 is converted to uppercase by the FPGA and can be read back from Endpoint 2.+The firmware (defined in [[en:projects:ucecho_fpga#firmwareucechoc|ucecho.c]]) declares Endpoint 2 and Endpoint 4 (both 512 bytes, double buffered, bulk transfer, belong to interface 0). All data that is written to Endpoint 4 is converted to uppercase by the FPGA and can be read back from Endpoint 2.
  
-The Bitstream for the FPGA configuration is defined in [[en:projects:usb_fpga-1.2_ucecho#bitstreamfpgaucechovhd|fpga/ucecho.vhd]]. The FPGA reads one byte per clock cycle from port ''PC'', converts it to uppercase and writes it to port ''PB''.+The Bitstream for the FPGA configuration is defined in [[en:projects:ucecho_fpga#bitstreamfpgaucechovhd|fpga/ucecho.vhd]]. The FPGA reads one byte per clock cycle from port ''PC'', converts it to uppercase and writes it to port ''PB''.
  
-The driver (defined in [[en:projects:usb_fpga-1.2_ucecho#java_host_softwareucechojava|ucecho.java]]) uploads the the Firmware (''ucecho.ihx'') to the EZ-USB Microcontroller and the Bitstream (''fpga/ucecho.bin'') to the FPGA if necessary, sends user string to the device and reads them back.+The host software (defined in [[en:projects:ucecho_fpga#java_host_softwareucechojava|ucecho.java]]) uploads the the Firmware (''ucecho.ihx'') to the EZ-USB Microcontroller and the Bitstream (''fpga/ucecho.bin'') to the FPGA if necessary, sends user string to the device and reads them back.
  
 Uploading the Firmware to EEPROM is also supported by the firmware (e.g. using the FWLoader utility). Uploading the Firmware to EEPROM is also supported by the firmware (e.g. using the FWLoader utility).
Line 377: Line 377:
     return 0;     return 0;
 } }
 +</code>
 +
 +
 +====== Python host software: UCEcho.py ======
 +
 +It is also possible to access the device with other programming languages. In this case the firmware must be loaded using the FWLoader utility included in the SDK. For testing you can run UCEcho.jar first and then run this file. For Python be sure to install [[http://pyusb.sourceforge.net/|PyUSB]].
 +
 +The Python source code of the host software is:
 +
 +<code python>
 +#   ucecho -- uppercase conversion example for ZTEX USB-FPGA Module 1.11c
 +#   Copyright (C) 2013 Colin O'Flynn <coflynn@newae.com>
 +#   Based on work from http://www.ztex.de
 +#
 +#   This program is free software; you can redistribute it and/or modify
 +#   it under the terms of the GNU General Public License version 3 as
 +#   published by the Free Software Foundation.
 +#
 +#   This program is distributed in the hope that it will be useful, but
 +#   WITHOUT ANY WARRANTY; without even the implied warranty of
 +#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 +#   General Public License for more details.
 +#
 +#   You should have received a copy of the GNU General Public License
 +#   along with this program; if not, see http://www.gnu.org/licenses/.
 +#
 +import sys
 +try:
 +    import usb
 +except:
 +    print "usb import failed. Install pyusb from http://pyusb.sourceforge.net"
 +    sys.exit()
 +    
 +
 +if __name__ == '__main__':               
 +
 +    #Find Device
 +    dev = usb.core.find(idVendor=0x221A, idProduct=0x0100)
 +
 +    if dev is None:
 +        print "Failed to find ZTEX Device, check idVendor & idProduct"
 +        print " You should run UCEcho.jar first, and then without unplugging"
 +        print " USB module run this program to ensure all devices are fully"
 +        print " programmed."
 +        
 +        sys.exit()
 +
 +    # set the active configuration. With no arguments, the first
 +    # configuration will be the active one
 +    dev.set_configuration()
 +
 +    #You can find these from the descriptors - see pyusb doc for an
 +    #example of this. I'm simplifying this because I know exact
 +    #interface & endpoint addresses
 +    writeEP = 0x04
 +    readEP = 0x82
 +    interface = 0
 +
 +    resp = "go"
 +
 +    while resp != "quit":
 +        resp = raw_input("Enter a string or `quit' to exit the program: ")
 +        dev.write(writeEP, resp, interface)
 +        print "Send %d bytes: `%s'"%(len(resp), resp)
 +        ret = dev.read(readEP, len(resp), interface, 100)
 +        retstr = ''.join([chr(x) for x in ret])
 +        print "Read %d bytes: `%s'"%(len(retstr), retstr)
 </code> </code>
  
 
 
Recent changes RSS feed Creative Commons License Powered by PHP Debian Driven by DokuWiki
[ZTEX Home] [Imprint] [Privacy policy]