Epics@GSI Webhome

Multi-purpose control implementation on HadCon for HADES



The objective is to combine all existing HadCon (HADControl general purpose board) implementations into one μController code for its ATMEL AT90CAN128:
  • CANbus (based on the thesis and work of L.Fouedjou, see Project Page)
  • One-Wire bus implementation
    • ADC
    • DAC
    • Temperature
    • Switches
  • HadCon's internals
    • DACs
    • ADCs
  • ...



  • HadCon
    • Power supply, 6V
    • Kernel programming: Sergey Yurevic, HADES
    • Schematic
    • Micro-controller: AT90CAN128
    • CPU: AXIS ETRAX 100LX MCM 4+16
    • CPLD: 64 Macrocell CPLD Xilinx (XC)R3064XL
    • Tweaks:
        Set fuses
        First time you are programming a new hadcon board with “Olimex” (s.below) you have to “set fuses” (up-to-now I don't now what this means) by issuing from your cross compiling computer the following sequence:
        $> avarice -c 0,1,0,4 --jtag /dev/ttyUSB0 -B 1000000 -W ff19e0
        Bridge Flip-flop to increase ATMEL_CLOCK to 10MHz
        to be able to transmit up to baud rates of 115200 you have to manipulate the hardware of the hadcon.
        The clock signal of the oscillator X1 is 20 MHz. It is scaled down by two flip-flops (UFF1, UFF2) first to 10 MHz and then to 5 MHz.
        Now 10 MHz are needed
        Therefore UFF2 has to be bridged or short-cut, i.e.
        1. pin 5 of UFF2 has to be disconnected from its pad and removed
        2. A cable has to be soldered connecting pin 1 of UFF2 to the solder pad of pin 5
        DHCP / NFS mount
        Etrax tries to NFS mount directories extracted from the DHCP information:
        1. At start-up the ETRAX board with its kernel sends an DHCP broadcast request with its MAC adress
        2. An special (private) DHCP server returns the needed network settings
        3. But the secondary DNS server address is taken as mount point to mount files from
        4. more about contact Sergey Yurevich at GSI
  • AVR-USB-JTAG Connector (olimex)
    • ADAN2: Connector
      • ADAN2 schematic,pdf: ADAN2 Measuring adapter
        • missing connection on pin 1 and 2 in the schematic, they connect one-to-one
        • final connection :
          AVR-JTAG-USB pin ADAN2 in pin JTAG hadcon in
          AVR name HadCon name
          TCK 1 9 9 TCK
          GND 2 8 8 GND
          TDO 3 7 7 TDIN
          VREF 4 - -  
          TMS 1 1 1 TMS
          NSRST 6 - -  
          VCC 7 5 5 +5V
          NTRST 8 - -  
          TDI 9 3 3 TDOUT
          GND 10 10 10 GND
    • make sure the user accessing the AVR-USB-JTAG has sufficient permissions
      • suse-linux:
        • user should be member of group dialout
        • before accessing change group by issuing the command: newgrp dialout
          • TODO: Check: are there smarter alteratives ???
  • Devices to connect to
    • CAN
    • 1-Wire
    • Registers
    • ...


Supported devices

Family code Device and datasheet
10h pdf DS18S20 1-Wire Parasite-Power Digital Thermometer
28h pdf DS18B20 1-Wire Programmable Resolution 1-Wire Digital Thermometer
20h pdf DS2450 1-Wire Quad A/D Converter
3Ah pdf DS2413 1-Wire Dual Channel Addressable Switch
05h pdf DS2405 1-Wire Addressable Switch
29h TODO pdf DS2408 1-Wire 8-Channel Addressable Switch



  • cvs repository :ext:[hadaq@]lxi001.gsi.de:/misc/hadesprojects/daq/cvsroot
  • cvs modules:
    • μController code (“API-Slave”) : hadcon/API-Slave
    • standalone test program (“API-Master”) : hadcon/API-Master




The basic operation principle is that
  • HadCon's ETRAX processor communicates via the serial interface (/dev/ttyS1) with the μController sending and receiving keyword based ASCII streams/strings (see Protocol below for details)
  • μController provides the communication with the (external) devices


Commands ( CPU → μController )

    In general the command HELP send to the device with
    $> /mnt/flash/API-Master "HELP"
    $> cat </dev/ttyS1 &
    $> echo >/dev/ttyS1 "HELP"
    will give a short list of available commands:

        RECV HELP --- available commands are:
        RECV HELP --- SEND : SEND CAN-ID ID-Range [RTR <nBytes> D0 .. D7]
        RECV HELP --- SUBS : SUBS CAN-ID ID-Range              
        RECV HELP --- USUB : USUB CAN-ID ID-Range              
        RECV HELP --- STAT : STAT [ID]                                            --- not implemented
        RECV HELP --- RGWR : RGWR Register Value               
        RECV HELP --- RGRE : RGRE Register                     
        RECV HELP --- RADC : RADC [<ADC Channel>]              
        RECV HELP --- OWAD : OWAD [ID [flag_conv [flag_init]]] 
        RECV HELP --- OWDS : OWDS [ID]                                            --- [ID] not implemented
        RECV HELP --- OWLS : OWLS [<Family Code>]              
        RECV HELP --- OWSS : OWSS [ID]                                            --- [ID] not implemented
        RECV HELP --- RSET : RSET                              
        RECV HELP --- PING : PING                              
        RECV HELP --- OWTP : OWTP [ID [flag_conv [flag_init]] | <command_keyword> [arguments]
        RECV HELP --- OWSP : OWSP <bus mask>                   
        RECV HELP --- ADSP : ADSP <bus mask>                                      --- not implemented
        RECV HELP --- RLSL : RLSL <bus> [val]                                     --- not implemented
        RECV HELP --- RLSH : RLSH <bus> [val]                                     --- not implemented
        RECV HELP --- RLSI : RLSI <bus> [pins]                                    --- not implemented
        RECV HELP --- RLSO : RLSO <bus> [pins]                                    --- not implemented
        RECV HELP --- DBGL : DBGL [level]                      
        RECV HELP --- DBGM : DBGM [mask]                       
        RECV HELP --- JTAG : JTAG                                                 --- not implemented
        RECV HELP --- HELP : HELP [CMND]                       
        RECV HELP --- OWTR : OWTR [ID] ...                                        --- not implemented
        RECV HELP --- OWRP : OWRP                              
        RECV HELP --- ADRP : ADRP                                                 --- not implemented
        RECV HELP --- DEBG : DEBG [level [mask]]               
        RECV HELP --- PARA : PARA parasitic device test [???]  
        RECV HELP --- SHOW : SHOW [key_word]                   
        RECV HELP --- OWMR : OWMR ID <pin_mask>                                   --- not implemented
        RECV HELP --- OWPC : OWPC [<pin_mask>]                                    --- not implemented
        RECV HELP --- OWRb : OWRb <pin_mask> <delay> <timeout: N (times delay)>   --- not implemented
        RECV HELP --- OWRB : OWRB [<pin_mask>]                                    --- not implemented
        RECV HELP --- OWSC : OWSC <command_key_word> [<pin_mask> [arguments ...]] --- not implemented
        RECV HELP --- OWSB : OWSB <byte> [<pin_mask>]                             --- not implemented
        RECV HELP --- OWSA : OWSA <command_key_word> [arguments]                  --- not implemented
        RECV HELP --- WDOG : WDOG [???]                                           --- not implemented
        RECV HELP --- EXIT : EXIT                                                 --- not implemented
        RECV HELP --- RLTH : RLTH [command_key_word] <value>   
        RECV HELP --- CMD1 : CMD1 [???]                                           --- not implemented
        RECV HELP --- CMD2 : CMD2 [???]                                           --- not implemented
        RECV HELP --- CMD3 : CMD3 [???]                                           --- not implemented
        RECV HELP --- CMD4 : CMD4 [???]                                           --- not implemented
        RECV HELP --- CMD5 : CMD5 [???]                                           --- not implemented
        RECV HELP --- CMD6 : CMD6 [???]                                           --- not implemented
        RECV HELP --- CMD7 : CMD7 [???]                                           --- not implemented
        RECV HELP --- CMD8 : CMD8 [???]                                           --- not implemented
        RECV HELP --- CMD9 : CMD9 [???]                                           --- not implemented

    A more detailed description you'll get by using the command:
    HELP command

    <Keyword, 4 letter, capital letters> <CAN Message-ID> <ID-Range> [<RTR> <Length> <Data0 ... Data7>]

    Keyword Action Format Description Comments
    SEND Send CAN Message SEND <CAN Message-ID> <ID-Range> [<RTR> <Length> <Data0 ... Data7>] Message-ID: CAN Message Identifier (hex)
    ID-Range: used as mask on Message IDs (hex)
    RTR: sets Remote Transmission Request Mode
    Length: number of data bytes to send (max: 8)
    Data0...7: 0 to 8 data bytes (hex)
    SUBS Subscribe to Message-IDs SUBS <CAN Message-ID> <ID-Range> Subscribe to react on (a range of) CAN Messages
    Message-ID: CAN Message Identifier (hex)
    ID-Range: used as mask on Message IDs (hex)
    TODO: look to code, has to be clarified
    USUB Unsubscribe from Message-IDs USUB <CAN Message-ID> <ID-Range> Unsubscribe from reacting on (a range of) CAN Messages
    Message-ID: CAN Message Identifier (hex)
    ID-Range: used as mask on Message IDs (hex)
    TODO: look to code, has to be clarified

Response ( μController → CPU )

    <Keyword, 4 letter, capital letters> <Message>

    Keyword Format Description Comments
    RECV <literal acknowledge> RECV <literal acknowledge> unspecified response
    Response when nothing to response
    ERRA ERRA <Error number> <Error description> Error in the serial communication API,
    e.g. wrong keywords, syntax errors
    ERRG ERRG <Error number> <Error description> general errors  
    Keyword Format Description Comments
    RECV <CAN Message> RECV <MOB-number> <CAN Message-ID> <ID-Range> [<RTR> <Length> <Data0 ... Data7>] positive data response
    MOB-number: index of receiving MOB (Message Object Blocks) in CAN controller
    Message-ID: CAN Message Identifier (hex)
    Length: number of data bytes sent (max: 8)
    Data0...7: 0 to 8 data bytes (hex)
    ERRC ERRC <Error number> <Error description> Error in the CAN communication,
    e.g. device not ready, not connected
    ERRM ERRM <Error number> <Error description> Error in the CAN controller's Message Object Blocks (MOB),
    e.g. too many subscriptions (max. 12)

last updated status & plans (-- PeterZumbruch - 13 May 2011)

  • OWTP, OWAD, OWLS seems to work
    • according to the manual OWTP delivers reasonable values 25 to 30
    • OWAD values have to be checked by users
  • optimize temperature conversion n_bus * 750 ms -> 1*750ms, make it optional
    • also done for adc
I will continue developing:
  • OWDS (read and (missing) write)
  • add the single ID access to the commands
  • split temperature conversion into an automatic task initiated every (5-10) seconds, (maybe) blocking 1-wire bus for 750 ms, but not the
  • API settings command: APIC command value(s)
  • check warnings
  • other possible devices
    • organizing local ADC support
      • including (already but rudimentary) existing relay / state machine control ( min < value < max )
    • I²C (in the far end)

  • Request to implement DS2408 8-Channel Addressable Switch, by RPC/HADES/Coimbra

- ...

Meanwhile ...

Due to several request I had to develop different features in different branches. The main task is now to merge all these projects into one, where this is its poor-mans backup tarball.

-- PeterZumbruch - 30 May 2011
Topic attachments
I Attachment Action Size Date Who Comment
SCHEMATIC1_PAGE1.pdfpdf SCHEMATIC1_PAGE1.pdf manage 15.0 K 2010-03-12 - 10:33 PeterZumbruch ADAN2 Measuring adapter
avr-mem.shsh avr-mem.sh manage 5.0 K 2010-04-01 - 09:12 PeterZumbruch avr-mem (original from http://www.mikrocontroller.net/topic/52953 http://www.mikrocontroller.net/attachment/18841/avr-mem.sh)
doc7679.pdfpdf doc7679.pdf manage 5152.0 K 2010-03-11 - 14:51 PeterZumbruch AT90CAN32/64/128 (428 pages, revision H, updated 8/08), local copy of http://www.atmel.com/dyn/resources/prod_documents/doc7679.pdf
hadcon-projects.7z7z hadcon-projects.7z manage 4154.4 K 2011-05-30 - 11:28 PeterZumbruch tar ball of all hadcon related projects, to be merged
Edit | Attach | Print version |  PDF | History: r38 | r23 < r22 < r21 < r20 | Backlinks | View wiki text | Edit WikiText | More topic actions...
Topic revision: r22 - 2011-05-30, PeterZumbruch
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding GSI Wiki? Send feedback
Imprint (in German)
Privacy Policy (in German)