Can't Wait for PropGCC on the P2?

124»

Comments

  • Here's some example diagrams of various servo diagrams. Most have at least parts of the basic PID spread around but most have extra components and, more importantly, the whole servo loop structure extends well beyond the PID fusing elements.

    And here's a related link to integrating modelling into the servo - https://www.routledgehandbooks.com/doi/10.4324/9780203132746.ch3
    "Since 1978, the cost of textbooks has risen 812%, outpacing even the cost of medical services and new housing."
  • And a significant input is always the left edge profile inputs - called various things like set temperature, target position - whatever the ideal control is.
    "Since 1978, the cost of textbooks has risen 812%, outpacing even the cost of medical services and new housing."
  • potatoheadpotatohead Posts: 8,733
    edited April 21 Vote Up0Vote Down
    I just had a random thought on this. I wonder if those neural nets can be trained on something like these problems? The benefit may be either auto tuning and or ability to operate with past experience. Run one, guide it, once done, ship it trained kind of thing.

    The number of inputs and desired output is generally small too. Might not even need to be a big net.

    The "past experience" may present as better stability and or faster arrivals at control target, like when humans do this knowing how a given system behaves.

    Once trained for a specific domain, they can be bit depth reduced to a fraction of their training and development size and depth and still function with high fidelity.

    Was reading a paper on this a few days ago. They took one for images and reduced it to 8 bits and then even fewer and it worked fine, but was small and used only basic CPU math. Their goal was to put the net on mobile, for example. Client side voice recognition, etc...

    I kind of want to play with the idea myself, but have no real target to test on. So, I'm just tossing it out there.

    Do not taunt Happy Fun Ball! @opengeekorg ---> Be Excellent To One Another SKYPE = acuity_doug
    Parallax colors simplified: http://forums.parallax.com/showthread.php?123709-Commented-Graphics_Demo.spin<br>
  • potatohead wrote: »
    I just had a random thought on this. I wonder if those neural nets can be trained on something like these problems? ...
    Heater will like this one (javascript) - http://rednuht.org/genetic_walkers/
    "Since 1978, the cost of textbooks has risen 812%, outpacing even the cost of medical services and new housing."
  • Neat!
    Do not taunt Happy Fun Ball! @opengeekorg ---> Be Excellent To One Another SKYPE = acuity_doug
    Parallax colors simplified: http://forums.parallax.com/showthread.php?123709-Commented-Graphics_Demo.spin<br>
  • Not sure how this topic wandered so far afield, but getting back to the tools for P2: Dave, your loadp2 and p2asm work great! Thank you for posting them. PNut is a quick way to get started, but for me nothing beats command line tools for productivity.

    Eric
  • Dave HeinDave Hein Posts: 5,114
    edited April 22 Vote Up0Vote Down
    jmg wrote: »
    Dave Hein wrote: »
    I got loadp2 running reliably under Linux, Cygwin and MinGW.
    Do the baud problems you mentioned before still persist ?
    Or can you now get to 2Mbd ok ? ( & all values below that ?)
    I ran some tests with loadp2 using only Prop_Txt and I was able to go up to 4Mbd on Linux. On a Windows machine I could only go up to 256Kbd. I haven't figured out how to get a higher rate on Windows yet, but it must be possible. PNut can load the large VGA demo program in about 2 seconds, which works out to about 2Mbd. BTW, Chip did mention in a post back in 2015 that PNut uses a 2-stage loader using MainLoader. The fact that user programs come up in the 80MHz mode also indicates that a 2-stage loader is used.
    ersmith wrote: »
    Not sure how this topic wandered so far afield, but getting back to the tools for P2: Dave, your loadp2 and p2asm work great! Thank you for posting them. PNut is a quick way to get started, but for me nothing beats command line tools for productivity.
    Thanks, Eric. Let me know if you find any problems, and I'll fix them as soon as I can. I'm going to work on loadp2 a bit more to get a higher baud rate, and to allow the user to set an operating baud rate for the program. I'll also post an update to s2p to fix a few issues.

  • jmgjmg Posts: 9,829
    Dave Hein wrote: »
    I ran some tests with loadp2 using only Prop_Txt and I was able to go up to 4Mbd on Linux. On a Windows machine I could only go up to 256Kbd. I haven't figured out how to get a higher rate on Windows yet, but it must be possible.
    Quite a difference, are they similar resourced PC's ? 4MBd is good :)
    Do they use the same serial-bridge device ? Which one ? One stop bit or two ?

    Autobaud will work above 2MBd region, but the granularity gets worse.
    If you are lucky with a Crystal-derived 20MHz and a Crystal-derived, or Crystal-locked 48MHz in USB bridge, 4MBd should extract with no offset, but 4MBd is less likely on a final device RC osc.

    The most capable bridge device for software testing is the FT2232H (crystal, and larger buffers) and then confirm more vanilla bridges like FT230X or CP2102N.
    Dave Hein wrote: »
    PNut can load the large VGA demo program in about 2 seconds, which works out to about 2Mbd. BTW, Chip did mention in a post back in 2015 that PNut uses a 2-stage loader using MainLoader. The fact that user programs come up in the 80MHz mode also indicates that a 2-stage loader is used.
    Interesting.
  • @Dave
    Here's my Windows app that I have been using to test the serial loader.
    It detects multiple P2's and generates Txt and Hex files too.
    Runs Ok @ 2Mbaud on my Pc's.
    I'm curious to see if it works on your machine.
    :)

    Melbourne, Australia
  • jmgjmg Posts: 9,829
    ozpropdev wrote: »
    Runs Ok @ 2Mbaud on my Pc's.
    What USB bridge devices did you test this with ?
    What version of Windows and appx CPU speed is the test PC ?

  • jmg wrote: »
    ozpropdev wrote: »
    Runs Ok @ 2Mbaud on my Pc's.
    What USB bridge devices did you test this with ?
    What version of Windows and appx CPU speed is the test PC ?
    Win10 Pro i7 3.6GHz
    Win 10 Home i7 2.5GHz laptop
    Win 10 Home Pentium 2.1GHz laptop

    All tests used Propplugs except for P123-A7 & A9 boards which used their on-board FT bridges (I don't have part number close at hand.)

    Melbourne, Australia
  • "Since 1978, the cost of textbooks has risen 812%, outpacing even the cost of medical services and new housing."
  • Just to be clear, the loadp2 serial speed limitation on Windows is a software limitation, and not hardware. Running PNut on my Windows machine appears to run at 2Mbd without a problem. The GCC libraries for MinGW and Cygwin provide maximum baud rates of 256000. This seems to be a Windows software limitation. However, there are clearly ways to get around it as shown by PNut and ozprodev's software. ozprodev, can you post your source code? What language did you write it in?
  • Dave Hein wrote: »
    Just to be clear, the loadp2 serial speed limitation on Windows is a software limitation, and not hardware. Running PNut on my Windows machine appears to run at 2Mbd without a problem. The GCC libraries for MinGW and Cygwin provide maximum baud rates of 256000. This seems to be a Windows software limitation. However, there are clearly ways to get around it as shown by PNut and ozprodev's software. ozprodev, can you post your source code? What language did you write it in?
    Are you trying to use the enum symbols for baud rate? I think you can just use the integer value instead of the symbols to get the higher baud rates.

  • Cygwin uses the rates defined in winbase.h, which is included from windows.h. They are defined as "#define CBR_xxxx xxxx", and they do match the numerical value of the baud rate. However, CBR_xxxx values only go up to 256000. The Bxxxx numbers are defined in termios.h, and the go up to B3000000, which is defined as 0x0100f. The 0x01xxx indicates it an extended baud rate. The routines that osint_cygwin.c uses to set the baud rate use the CBR_xxxx values, and not Bxxxx.

    I've tried using the numerical value, but nothing seems to work above 256000. For values below that, I think the driver uses the nearest CBR_xxxx rate.

    Serial ports are treated differently in Windows than they are in Linux. In Linux the serial file structure can be manipulated just like any other file. That's not the case in Windows. There must be a way to increase the baud rate under Windows, but I just haven't figured out how to do it yet. An internet search shows that many people of encountered this problem. I keep searching, but if I can't find a quick solution I just leave it at 256Kbd for now.
  • Dave Hein wrote: »
    Cygwin uses the rates defined in winbase.h, which is included from windows.h. They are defined as "#define CBR_xxxx xxxx", and they do match the numerical value of the baud rate. However, CBR_xxxx values only go up to 256000. The Bxxxx numbers are defined in termios.h, and the go up to B3000000, which is defined as 0x0100f. The 0x01xxx indicates it an extended baud rate. The routines that osint_cygwin.c uses to set the baud rate use the CBR_xxxx values, and not Bxxxx.

    I've tried using the numerical value, but nothing seems to work above 256000. For values below that, I think the driver uses the nearest CBR_xxxx rate.

    Serial ports are treated differently in Windows than they are in Linux. In Linux the serial file structure can be manipulated just like any other file. That's not the case in Windows. There must be a way to increase the baud rate under Windows, but I just haven't figured out how to do it yet. An internet search shows that many people of encountered this problem. I keep searching, but if I can't find a quick solution I just leave it at 256Kbd for now.
    Maybe ask Chip how he did it in PNut?

  • @Dave
    My code was written in Visual Basic 2015.
    Here's the source code.
    Not sure it will be much help to you though.
    :(
    Melbourne, Australia
  • jmgjmg Posts: 9,829
    Dave Hein wrote: »
    Just to be clear, the loadp2 serial speed limitation on Windows is a software limitation, and not hardware. The GCC libraries for MinGW and Cygwin provide maximum baud rates of 256000.

    Wow, really, seems like the dark ages....
    I recall RaspPi also had similar imposed limitations, but they were quickly fixed.
    Dave Hein wrote: »
    This seems to be a Windows software limitation.
    Well, maybe a windows-side software problem, related to MinGW and Cygwin, and not so much a 'Windows software limitation'
    Dave Hein wrote: »
    However, there are clearly ways to get around it as shown by PNut and ozprodev's software. ozprodev, can you post your source code? What language did you write it in?
    Running PNut on my Windows machine appears to run at 2Mbd without a problem.
    IIRC PNut uses Freepacal, and above ozpropdev says Visual Basic 2015

    I'm a little stunned the much-vaunted C is stuck way back in the past, with enum locked Baud values.
    Serial hardware was never really enum locked, and for a long time it's been possible to use a LONG to define BAUD.
    The better USB serial ports deliver their nearest BAUD value, (up to 3MBd, 12MBd, 15MBd), some older/poorer drivers will spit an error.
    That's why a variable baud choice, and 115200 default is a good idea.

    Dave Hein wrote: »
    I've tried using the numerical value, but nothing seems to work above 256000. For values below that, I think the driver uses the nearest CBR_xxxx rate.
    Hmm, don't you just hate it when some coder from the past, thinks they know best, and over-rule your values... :(
    Dave Hein wrote: »
    An internet search shows that many people of encountered this problem.
    Surely someone has solved it, or are those C-flows not that widely used for multi-platform development ?

    Here, we run serial COMs in FreePascal or FreeBasic - both allow Longs for Baud, and accept any value.
    The USB-Bridge driver then either uses closest, or gives an error.

    I've also used Synaser libraries, mentioned with links here :
    http://wiki.freepascal.org/Hardware_Access

    Seems good dual-platform support and examples here,
    Source is here... with both unix and windows forms.
    https://www.ararat.cz/synapse/doku.php/download

    and the synaser.pas has this record defined, (I think this is Windows Control Block record ?)
    type
      TDCB = record
        DCBlength: DWORD;
        BaudRate: DWORD;
        Flags: Longint;
        wReserved: Word;
        XonLim: Word;
        XoffLim: Word;
        ByteSize: Byte;
        Parity: Byte;
        StopBits: Byte;
        XonChar: CHAR;
        XoffChar: CHAR;
        ErrorChar: CHAR;
        EofChar: CHAR;
        EvtChar: CHAR;
        wReserved1: Word;
      end;
      PDCB = ^TDCB;
    

    I think you can change the BaudRate in that record, and sidestep other code that limits your choices ?



  • Well it turns out that I can specify a baud rate that is not in the list of defined constants. So David Betz was correct about this. I had to add a couple of delays to get things to work. One delay was added after the secondary loader was loaded, and before I started to load the user program. The second delay was added after the user program was loaded and before changing the baud rate to the user baud rate. So now I'm able to load at 2Mbd.
  • jmgjmg Posts: 9,829
    Dave Hein wrote: »
    Well it turns out that I can specify a baud rate that is not in the list of defined constants.
    That makes more sense, as most systems I've used can accept the Baud as a 32b number.
    Dave Hein wrote: »
    So David Betz was correct about this. I had to add a couple of delays to get things to work. One delay was added after the secondary loader was loaded, and before I started to load the user program. The second delay was added after the user program was loaded and before changing the baud rate to the user baud rate. So now I'm able to load at 2Mbd.
    What delays are needed ?
    There seems multiple levels here ? Is that 2MBd for the 64b encoded, 20MHz boot download portion ?
    I think ozpropdev was using just a single large block copy, of the 64b, 20MHz boot ?


  • jmg wrote: »
    I think ozpropdev was using just a single large block copy, of the 64b, 20MHz boot ?

    That's correct, just a P2 reset then burst the 64b encoded chunk @2Mbaud.
    Melbourne, Australia
  • I use 50ms after the reset, and 100ms for the other two delays.
    Yes, there are multiple levels. I use 2MBd for both levels. I use Prop_Hex rather than Prop_Txt, though I have tried both. Prop_Hex is easier to use.

    I have used Prop_Txt to download the user program, but MainLoader is 25% faster than Prop_Txt, so why not use it? MainLoader has the added benefit of pre-setting the clock rate to 80MHz. In the future I might add a checksum at the end just to verify that the code loaded correctly. I can't do that with Prop_Txt.
  • jmgjmg Posts: 9,829
    edited April 23 Vote Up0Vote Down
    Dave Hein wrote: »
    I use 50ms after the reset, and 100ms for the other two delays.
    Yes, there are multiple levels. I use 2MBd for both levels.
    Thanks, I was wanting to check you have the 20MHz loader running up to 2MBd.

    Dave Hein wrote: »
    I use Prop_Hex rather than Prop_Txt, though I have tried both. Prop_Hex is easier to use.
    True, but at the expense of speed.
    Dave Hein wrote: »
    I have used Prop_Txt to download the user program, but MainLoader is 25% faster than Prop_Txt, so why not use it?
    MainLoader has the added benefit of pre-setting the clock rate to 80MHz.
    Sure, two stage loaders have a place, and if you go to 80MHz, you probably can support 6MBd Stage 2 speeds. (FT2232H, FT232H)
    Adafruit have this https://www.adafruit.com/product/2264

    Is it also important to have the ROM download supported up to the top practical speed, as that is simplest and gives an easy to diagnose base.
    Dave Hein wrote: »
    In the future I might add a checksum at the end just to verify that the code loaded correctly. I can't do that with Prop_Txt.
    Good point, I thought Chip had some ROM loader checksum capability, but I do not see it in the docs ?
  • jmgjmg Posts: 9,829
    Dave Hein wrote: »
    .. In the future I might add a checksum at the end just to verify that the code loaded correctly. I can't do that with Prop_Txt.
    Reading the DOCs multiple times, I think there is a verify-echo possible, as in


    ..
    Before sending the final “~” character, it is a good time to poll the error status by sending a “?” character and waiting for either the “.” (okay) or “!” (error) character to come back. In the case of a signature and a large program, it will take about one second per 100KB of loaded program (not sent text) to compute the SHA-256/HMAC signature, before a response character will be sent.
    ..
    Sender: “> Prop_Hex 0 0 0 0 FB F7 23 F6 FD FB 23 F6 25 26 80 FF 28 80 66 FD F0 FF 9F FD ~”
    In case the key was zero and you wanted to sign the data, anyway:

    Sender: “> Prop_Hex 0 0 0 0 FB F7 23 F6 FD FB 23 F6 25 26 80 FF 28 80 66 FD F0 FF 9F FD | 4B 7D 21 17 27 EE 87 C0 DD 47 D4 A8 70 5B C5 F1 6F 6D 9B 81 44 83 E6 B3 20 51 28 BE 5D D8 85 40 ~”

    To do the same, but also poll for an error after the signature has been checked (note the space before the “?”):

    Sender: “> Prop_Hex 0 0 0 0 FB F7 23 F6 FD FB 23 F6 25 26 80 FF 28 80 66 FD F0 FF 9F FD | 4B 7D 21 17 27 EE 87 C0 DD 47 D4 A8 70 5B C5 F1 6F 6D 9B 81 44 83 E6 B3 20 51 28 BE 5D D8 85 40 ?”

    Loader: “.”
    Sender: “~”
    It’s a good idea to start each hex data line with a “>” character, to keep the baud rate tightly calibrated.

    Prop_Txt

    The Prop_Txt command is like Prop_Hex, but with one difference: Instead of hex bytes separated by whitespaces, it takes in Base64 data, which are text characters that convey six bits, each. This format is 2.25x denser than hex, and so minimizes transmission size and time. Any signature bytes, however, must still be expressed in hex.


    I think that merges to something like this, Prop_Txt + 32 byte signed ?

    Sender:
    “> Prop_Txt 0 0 0 0 +/cj9v37I/YlJoD/KIBm/fD/n/0 | 4B 7D 21 17 27 EE 87 C0 DD 47 D4 A8 70 5B C5 F1 6F 6D 9B 81 44 83 E6 B3 20 51 28 BE 5D D8 85 40 ?”
    Wait for Loader: “.” (okay) or “!” (error) ( appx one second per 100KB of loaded binary program)
    Sender: “~”
  • jmgjmg Posts: 9,829
    edited April 24 Vote Up0Vote Down
    Dave Hein wrote: »
    ...
    Serial ports are treated differently in Windows than they are in Linux. In Linux the serial file structure can be manipulated just like any other file. That's not the case in Windows. There must be a way to increase the baud rate under Windows, but I just haven't figured out how to do it yet. An internet search shows that many people of encountered this problem. I keep searching, but if I can't find a quick solution I just leave it at 256Kbd for now.

    I know this is pretty much sorted now, but I spotted this over in AVR land, which is a Python Loader for their newest Debug Interface.

    https://github.com/mraardvark/pyupdi/blob/master/updi/physical.py
    https://github.com/mraardvark/pyupdi


    They've been quite smart here, instead of custom complex debug protocols, or pin-consuming SPI, they've chosen a Serial-UART-variant.
    This means they need a calibrated clock, but all small MCUs have those these days.

    Elements :
    They vary Baud rate to send a double BREAK, as 1200Bd.BreakChar.50ms.1200Bd.BreakChar.50ms (BreakChar = 0x00)
    I don't think that Autobauds here, just gives a solid state engine reset.
    (tho one could use a known-width-break to Clock-Cal, here 7.500ms wide, and Bit-time = BreakW/864, a 9600Bd Break would select 921600Bd)
    Then, they use 115200 as a default speed (use PARITY_EVEN, STOPBITS_TWO & these are much smaller chips than P2), and I spot this...
    # Inter-byte delay
            self.ibdly = 0.0001
    
    Curious, as I've not seen delays under 1ms used around FS USB Bridges, as that's the USB frame time.
    Not sure you can realistically ask any OS to pace such an elastic link, to 0.1ms ?
    They seem to be hoping to allow for a half-duplex reply ?
    12/115200 = 104.166us 11/115200 = 95.486us 10/115200 = 86.805us

    If the echos are rare, and carefully paced bursts, they could get away with this.

    Their half-duplex is wired
                             Vcc                     Vcc
                            +-+                     +-+
                             |                       |
     +---------------------+ |                       | +--------------------+
     | Serial port         P-+                       +-P  MCU device        |
     |                     |      +----------+         |                    |
     |                  TX O------+   4k7    +----o----IO  UPDI             |
     |                     |      +----------+    |    |                    |
     |                     |                      |    |                    |
     |                  RX I----------------------+    |                    |
     |                     |                           |                    |
     |                     G--+                     +--G                    |
     +---------------------+  |                     |  +--------------------+
                             +-+                   +-+
                             GND                   GND
    
    

    All of this could port over to P2, Half Duplex, and Full Duplex ?
    It would be nice to have One-Pin P2 boot working from a Standard PC host, till now I've been planning on a local MCU for one-pin cases.
    Has anyone tried Python at 2Mbd ?

  • I've updated s2p, p2asm and loadp2 and put them all in the attached zip file. loadp2 can now load a file without specifying the serial port. I also added a script file called c2b that will compile and assemble a C file, and then load it into a P2 FPGA board.
Sign In or Register to comment.