Shop OBEX P1 Docs P2 Docs Learn Events
DEBUG OBJECT..a simple one.. — Parallax Forums

DEBUG OBJECT..a simple one..

dennodenno Posts: 223
edited 2014-12-14 17:08 in Propeller 1
OK...for over and I mean OVER 10 years, I have been a loyal user of the Basic Stamp, especially the BS2sx, with it's 8 program slots, and most of my apps, use all eight. Anyways, since, it would appear that Parallax is coming out with a Propeller, for embedded apps, like the stamp (self contained, if you will), I have decided that I would try and learn SPIN. I have been doing alot of homework, with various books, and tutorials from Parallax and the web. Certainly isn't as easy as PBASIC...but....

I have been using the Parallax Serial Terminal for DEBUGGING...BTW...The DEBUG function in PBASIC is really...really helpful. Keeping that thought in mind, Here is my question. Is there a simpler OBJECT that someone has written that would mirror the way the DEBUG works in PBASIC. In other works, Show the OBJECT for DEBUGGING in the TOP FILE, load the OBJECT in the COG of choice, so one knows where it is, then when writing the program, one could 'insert' a "DEBUG" phrase, which would open up the Parallax Serial Terminal...AND...ENABLE it, just like PBASIC. (Big pain in the ***, to have to ENABLE it everytime)..

Any thoughts from you SPIN masters?

DenO

Comments

  • max72max72 Posts: 1,155
    edited 2014-11-30 05:32
    Hi,
    this is my usual approach:
    I use the Parallax serial terminal object. It's more complex than the DEBUG (there is an object emulating DEBUG) but more flexible and powerful.
    You simply have to set the baud rate and you are done.
    On some boards there is a problem with USB serial connection with no cable connected, that causes chip reset.
    OBC wrote a dummy version of the Parallax serial terminal, that I use as an alternative (it's just chamging the object name, one line and debug is disabled.
    http://forums.parallax.com/attachment.php?attachmentid=70219&d=1273608817
    With the propeller tool there are little alternatives. But you can use BST. Not sure if PropellerIDE already implements it...
    https://lamestation.atlassian.net/wiki/display/PI/Downloads

    Massimo
  • dennodenno Posts: 223
    edited 2014-11-30 11:33
    Thanks...max72, but...since I am a newbe...could you provide alittle more info on how to insert the "Dummy" version into a SPIN program?
    Thanks..Denno
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-11-30 12:10
    You can press F12 to enable the terminal from the Propeller Tool (and I think Simple IDE).

    Having a statements inside the program open and enable the terminal window isn't possible from Spin alone. You'd need your editing software modified to do this.

    You can turn off the feature that disables the terminal when you select a different window. The problem here is you need to remember to "Disable" the terminal window before loading a new program. Windows won't let two programs access the same (virtual) serial port.

    The ease of adding debug statements was the main thing I missed when I switched to the Prop from the BS2. It didn't take long to get used to using the various serial objects and they're so much more powerful than anything the Stamp could do. The program doesn't have sit and wait for serial input when using the Prop. This opens up a lot of possibilities.
  • ErNaErNa Posts: 1,752
    edited 2014-11-30 13:43
    for a simple debugger: see here: http://www.insonix.ch/propeller/
  • dennodenno Posts: 223
    edited 2014-12-02 04:40
    Hello ErNa...thank you for the link. However, my computer...via Chrome...says that link could/would be dangerous to download and open. No offence, but has anyone else used/downloaded the link for PROPTERMINAL...thank you all...DennO
  • PublisonPublison Posts: 12,366
    edited 2014-12-02 05:21
    It's a safe site. Has been used my time over the years by forum members.
  • dennodenno Posts: 223
    edited 2014-12-03 12:37
    All right-ty...Again I am a newbe to the prop. Could use alittle guidence here, as I am getting no where. What I am trying to do is us the "Simple Asynchronous Serial Driver v1.3" by Jon Williams and others to run a Scott Edwards LCD, which I have used alot with the Basic Stamps. The idea is to be able to use that OBJECT and LCD as a DEBUG screen. I want to put a method call in the program that I am trying to write, so when I download it and run it, I will be able to see the result of a DEBUG command on the LCD, instead of using the Simple Serial Terminal. In other words, I would put something like DEBUGterminal.??? (result) in OBJECT that I am writing and I would be able to see if that result is what I am looking for, on the LCD. Instead of having to opening something like the Parallax Serial Terminal, and then clicking on the "ENABLE" button. I guess I want to see more of an instant readout. Plus the Scott Edwards LCD only needs one I/O to operate, not 7.

    I would appreciate any and all help on this...

    DennO
  • JDatJDat Posts: 103
    edited 2014-12-03 12:56
    CON
    
      'Set up the clock mode
      _clkmode = xtal1 + pll16x
      xinfreq = 5_000_000
      '5 MHz clock * 16x PLL = 80 MHz system clock speed
    
    VAR
    
    long variable
    
      
    OBJ
      serial        : "FullDuplexSerial"
     
    PUB Main
    serial.Start(31, 30, %0000, 9_600)    'start serial port
    
    repeat          'repeat forever
      serial.str(string("Before increment: "))    'swite text to serial port
      serial.dec(variable)
      serial.tx(13)    'new line
      variable:=variable+1      'variable++ is better
      serial.str(string("After increment: "))
      serial.dec(variable)
      serial.tx(13)    'new line
    

    Now open serial terminal with F12 and...
  • dennodenno Posts: 223
    edited 2014-12-04 15:16
    I am having trouble...yes, again with the Parallax Serial Terminal. This is what I have done..I have been able to send a STRING from the top object file to the PST, and by using the "PST.startRxTx" method and changing the I/O pin to 1 for Tx. So it looks like this....PST.startRxTx(0,1,0,9600). I am only transmitting to the display and not receiving. Now, I am sending the data, NOT to the computer screen, using the Parallax Serial Terminal, but I am sending the data to a Scott Edwards LCD. All the above works, when I use PST.str(STRING("............."). But, I cannot figure out how to send a number(s) or variable to the LCD, using PST.dec(value).

    what I am wanting to do is monitor a changing variable using PST.dec(value) while the program runs on the Scott Edwards LCD. This is why I want to use the LCD display, instead of the computer screen via Parallax Serial terminal. This way, I do not have to constantly hit F12 and ENABLE.

    I would appreciate any expert help on this..

    dennO
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-12-04 15:33
    If you post your code between code tags, we could offer suggests on how to improve it.

    To use code tags start with [noparse]
    then add your code (copy and paste) and finish with
    
    [/noparse]. Your code will then appear formatted correctly (similar to JDat's code in post #9).

    Tell us the expected output from the code and what the actual output is.

    JDat's code includes an example of using the "Dec" method to display variables. The "Parallax Serial Terminal" object is very similar to the "FullDuplexSerial" object JDat used and the Dec method in both objects have similar output.
  • JDatJDat Posts: 103
    edited 2014-12-05 11:51
    I am usually ose at least 2 Serial ports.
    Port 1 for Propeller IDE (programming) or Propeller Assembly Sourcecode Debugger (PASD).
    Port 2 for debug. Parallax Terminal or RealTerm.
    Sometimes it ir really handy when You can press F11 on Propeler Tools to upload latest code and don't need to enable/disable/whatever do on terminal.
    Port3 This port will work when everything will be finishet (production or DUT port).
    On port 3 I connect connected Basic stamp/Bluetooth/PC program/Android/ZigBee/serial LCD/DMX etc.
    It's sometimes handy when I can redirect Port3 to Port2. I can see on debug terminal what going on on production port and send data to system directly from debug port.
    Really flexible system.
  • dennodenno Posts: 223
    edited 2014-12-08 16:00
    Thank you to all posters...I was able to figure out how to transmit DEBUG info to a Scott Edwards 440 LCD (4 lines, 40 characters). PROTO_LCD.spin works well as the OBJECT. Keep in mind, I only wanted/needed to transmit a DEC value or a STRING to check my programming. Thanks DenO
  • JonnyMacJonnyMac Posts: 9,105
    edited 2014-12-14 12:48
    I am the artist formerly known as Jon Williams.

    I've attached a simple serial (no cog required) driver for the Parallax Serial LCD -- it could be modified for other serial LCDs. This object has decimal formatting which I like.

    One thing to keep in mind: DEBUG takes time out of your BS2 program loop. So will this object. Once you get a handle on using Spin and multiple cogs, what you can do is start a debugging cog that spits important data out a serial port (serial LCD or terminal). I do this all the time. Now, this only works for global variables (but a global can be a pointer to a method local [getting a little adnvaced]). The great thing is that the debugging output, once you've set it up, just happens when you run the program and does not interfere with your main loop timing.

    True story: I developed a DMX product for a customer that used my debugging cog strategy. One day the customer called me and asked if I could add the ability for him to see the raw DMX values coming into the device. I said, "Sure -- just connect a PropPlug to the board, open PST, set it to 115_200, and then reboot." I needed that information to track things during development, and I left it in the code.
  • JDatJDat Posts: 103
    edited 2014-12-14 13:03
    JonnyMac wrote: »
    True story: I developed a DMX product for a customer that used my debugging cog strategy. One day the customer called me and asked if I could add the ability for him to see the raw DMX values coming into the device. I said, "Sure -- just connect a PropPlug to the board, open PST, set it to 115_200, and then reboot." I needed that information to track things during development, and I left it in the code.

    Hehe. Sounds really similar to my approach. Use "original" serial (pins P30,P31) for debug/firmware upload and add another serial port, if it is necessary for costumer project.
  • cavelambcavelamb Posts: 720
    edited 2014-12-14 17:08
    Duane Degn wrote: »
    If you post your code between code tags, we could offer suggests on how to improve it.

    To use code tags start with [noparse]
    then add your code (copy and paste) and finish with
    
    [/noparse]. Your code will then appear formatted correctly (similar to JDat's code in post #9).

    Tell us the expected output from the code and what the actual output is.

    JDat's code includes an example of using the "Dec" method to display variables. The "Parallax Serial Terminal" object is very similar to the "FullDuplexSerial" object JDat used and the Dec method in both objects have similar output.


    Maybe if the code tags were shown on the editor page people would find it easier to use?
Sign In or Register to comment.