Shop OBEX P1 Docs P2 Docs Learn Events
Get data from Notepad into Propeller — Parallax Forums

Get data from Notepad into Propeller

zpuazpua Posts: 33
edited 2011-08-23 10:44 in Propeller 1
Hello All,

I would like to use attached Propeller code to get data from notepad by FullDuplexSerialPlus into the propeller via serial port.

Can anyone provide some comments for my programming please? I am learning that from the propeller manual v1.1 pg 107.

Thank you so much.
«134

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-17 11:59
    A Propeller program can't simply "reach into" your PC via the serial port and grab data from a program. There needs to be a program running on the PC to send the data. You might be able to find a print driver that can transmit data in "raw" mode to your serial port. Then you can print from Notepad using that driver.

    -Phil
  • zpuazpua Posts: 33
    edited 2011-08-17 12:09
    Phil,

    Can you please give more information about the print driver? Where can I look for the print driver and turn it on?

    Thank you.
  • LeonLeon Posts: 7,620
    edited 2011-08-17 12:11
    Most terminal programs can open a text file and transmit the data in it via a serial port. You could get the data into the Propeller that way.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-17 12:20
    Go to the Windows control panel, select Printers and Faxes, right click in the window that comes up, and click Add Printer. Click Next until you get to the window that lets you select a com port, and make your selection. In the next window, under Manufacturer, select Generic, and under Printers, select Generic/Text Only. Once the printer is installed, you can modify its Properties to set the baud rate and handshaking.

    -Phil
  • zpuazpua Posts: 33
    edited 2011-08-17 12:48
    Phil,

    I have installed a new Generic/Text Only printer driver. But I am still lost on how to use my propeller code to control the data transmitted from notepad to my propeller chip. Can you give more comment please?

    Thank you.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-17 12:52
    Your Propeller code can't control the print process (unless you use handshaking, but don't go there if you're not familiar with it). You have to write your Propeller program to wait for and read the data; then, from Notepad, print the file to the connected port using the generic printer you just installed.

    -Phil
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-08-17 13:14
    I would like to ask for more information:

    what are you gonna do with the text if it is t
  • zpuazpua Posts: 33
    edited 2011-08-17 14:10
    Stefan,

    The data stay the same when it is in the propeller. They are not text but they are values, around 200 data.

    I would like to use those values transmitted into propeller and compare(subtraction) them with the values that are already executed by the propeller.

    Any suggestion please? Thank you.
  • zpuazpua Posts: 33
    edited 2011-08-17 14:15
    Phil,

    May I know where can I look for the example of propeller programming code that programs wait for and read data?

    Thank you.
  • $WMc%$WMc% Posts: 1,884
    edited 2011-08-17 14:44
    zpua:
    '
    Have you looked at how PST works? (Parallax Serial Treminal)
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-08-17 14:49
    Do I remember right that you asked that a few days ago and that PhiPi suggested using an Excel-sheet?

    Typing 200 values into the propellertool into a DAT-section will take half an hour. (9 seconds per value)

    Trying to code a program receiving data from a generic printer will take half a week. With low programming skills half a month.
    As you are asking I guess you want to finish the project. So typing the values directly into the propeller-tool is faster.

    best regards

    Stefan
  • zpuazpua Posts: 33
    edited 2011-08-17 14:56
    Stefan,

    I have attached a code here. Is that what you mean by typing it into the propeller?

    Thank you.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-17 15:02
    After all my pontificating, I decided I'd better try it myself. 'Turns out, it's not as easy as I thought it would be. The problem is that, even with handshaking turned off, the printer driver toggles DTR, which resets the Propeller. Unfortunately, I know of no way around this problem.

    What, exactly -- in detail -- are you trying to do? Maybe there's another way to accomplish your objective. If the data are static, which appears to be the case, cut-and-paste or the FILE statement will probably do the job.

    -Phil
  • PliersPliers Posts: 280
    edited 2011-08-17 16:12
    I used visual basic express to send and receive data. It would read a text file from the hard drive and send it out the serial port.
    I was practicing filling and reading arrays.
    I'll look and see if I still have the code.

    Here is a link to visual basic express, it's free. http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-basic-express
  • idbruceidbruce Posts: 6,197
    edited 2011-08-17 16:41
    Is Parallax Serial Terminal open source?

    Bruce
  • kwinnkwinn Posts: 8,697
    edited 2011-08-17 17:00
    After all my pontificating, I decided I'd better try it myself. 'Turns out, it's not as easy as I thought it would be. The problem is that, even with handshaking turned off, the printer driver toggles DTR, which resets the Propeller. Unfortunately, I know of no way around this problem.

    What, exactly -- in detail -- are you trying to do? Maybe there's another way to accomplish your objective. If the data are static, which appears to be the case, cut-and-paste or the FILE statement will probably do the job.

    -Phil

    I have used true PC serial ports for similar functions in the past (not to the propeller though) and it works very well. Of course then I had complete control over what signals I connected. Could the programming cable not be connected to another header that is wired to different pins on the prop and use one of the serial objects? As long as the reset is not connected to the prop it should be ok shouldn't it?
  • BeanBean Posts: 8,129
    edited 2011-08-17 17:24
    Phil,
    Does it work if you just copy the file to the com port from the command prompt ?

    COPY myfile.txt COM1:

    Bean
  • $WMc%$WMc% Posts: 1,884
    edited 2011-08-17 17:35
    Heres and open source serial terminal.
    '
    Super Simple to use.
    '
    download a free version of JustBASIC v.1.01 to open the file with.
    '
    www.justbasic.com
    '
    This isn't any different then the PST though.
    '
    Sorry for the typo in the file name, But it still works
    '
    set Baud to 115200 for the Prop.
  • idbruceidbruce Posts: 6,197
    edited 2011-08-17 17:49
    @Phil
    A Propeller program can't simply "reach into" your PC via the serial port and grab data from a program.

    Hmmmm..... Now that is very interesting.

    Your right, the Propeller could not do that, but a serial monitoring program on the PC side could easily accomplish this, but this would exclude the Parallax Serial Terminal. However, I am sure it would not be to difficult to replicate the Serial Terminal functionality with a monitoring program.

    Suppose that the Propeller stored a known file path, for example C:\Documents and Settings\Bruce\Desktop\Data.txt, and let's suppose this file had a known structure of two values, each on a seperate line within the text file. In the Propeller there is an object, with the various methods, Start(which includes the previously mentioned file path), GetValue1, and GetValue2.
    CON
      _CLKMODE        = XTAL1 + PLL16X
      _XINFREQ        = 5_000_000
      TX              = 30
      RX              = 31
      COMM_MODE       = 0
      COMM_BAUD_RATE  = 9_600
    DAT
      DataFilePath BYTE "C:\Documents and Settings\Bruce\Desktop\Data.txt", 0
    VAR
      LONG Value1
      LONG Value2
    OBJ
      PCData : "PCData"
     
    PUB Main
     
      'Start Serial Comm
     
      PCData.Start(DataFilePath, RX, TX, COMM_MODE, COMM_BAUD_RATE)
     
      'Send two values to the PC software with a GetValue method of the PCData object,
      'eg. GetValue(FileLine, Value)
     
      'The PC software would open the file set by DataFilePath and iterate the file
      'lines until the first line of text was found, store the data of that line in
      'a variable, and close the file.  Upon closing the file, the PC software would
      'send that value back to the Propeller.
     
      PCData.GetValue(1, Value1)
     
      'The PC software would open the file set by DataFilePath and iterate the file
      'lines until the second line of text was found, store the data of that line in
      'a variable, and close the file.  Upon closing the file, the PC software would
      'send that value back to the Propeller.
     
      PCData.GetValue(2, Value2)
     
    

    Just a thought. :) Does anyone else have a use for something like this?

    Bruce
  • idbruceidbruce Posts: 6,197
    edited 2011-08-17 18:06
    @Walt

    You say this is just like PST. Have you used it with the Propeller?

    My previous post gives me a bunch of fresh ideas for machine control, and passing data between a PC and a Propeller.
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2011-08-17 18:15
    idbruce wrote:
    Is Parallax Serial Terminal open source?

    Yes, it is... http://www.parallax.com/OpenSourceHardwareDesigns/tabid/865/Default.aspx
  • idbruceidbruce Posts: 6,197
    edited 2011-08-17 18:23
    @Kevin Wood

    I appreciate the effort and post. I believe that must be Delphi, because it looks Greek to me. I wish it was in Visual C++.

    Bruce
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2011-08-17 18:33
    @Phil Pilgrim, using the printer is a great idea, I had never really thought about using the generic text printer to download data, I had fun experimenting.

    Of course your right about the reset problem but I overcame that using P0 and P1 with a MAX3232 while using P30 and P31 for the debug terminal, there was also a header and footer that had to be stripped from the text.

    Anyway the MAX chip with printer driver is possibly another solution for zpua.

    Jeff T.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-17 18:39
    Unsoundcode,

    You can eliminate the header and footer in Notepad's Page Setup menu.

    -Phil
  • $WMc%$WMc% Posts: 1,884
    edited 2011-08-17 19:27
    Hello Bruce
    '
    Yes it works really well with the Prop. @ 115200 Baud.
    '
    I had the Baud set to 9600 in the file I sent for use with the BS2. I added a note to use 115200 Baud for the Prop.
    '
    PropBASIC will really crank-up the Baud rate.
    '
    Add a 6.25MHz xtal and crank-it up some more.
    '
    I have used this method to send "home made (G) type code" info to the Prop with PropBASIC a 300K Baud +
    '
    My point in the reply was to show how easy it is to write a serial terminal program that one could easily send " txt " files at speed.
    '
    The PST will do this, But you would have to paste the code in the PST window.
    '
    My Serial Terminal is really open and easy to modify.One could easily go and find the txt file with some added code and send it out to what ever you wanted.
    '
    I can add some more info if needed.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-17 19:32
    $WMc% wrote:
    The PST will do this, But you would have to paste the code in the PST window.
    In my experience, text pasted into the PST input window causes one garbage character to be sent, and that's it.

    -Phil
  • idbruceidbruce Posts: 6,197
    edited 2011-08-17 19:32
    Walt

    For the last hour, I have been looking at a multiple VC++ Serial Comm project. It contains 5 different programming workspaces rolled into one. If I could just figure this out, I am sure it would be a breeze to accomplish the task as presented.
  • idbruceidbruce Posts: 6,197
    edited 2011-08-17 19:46
    I just figured out this VC++ cluster, but I also realized I have no unused props to experiment with :(
  • $WMc%$WMc% Posts: 1,884
    edited 2011-08-17 19:56
    Bruce
    '
    Basic is all around so much easier to use to Me.
    '
    But if you like all the Voids and // 's Then roll with it.
    '
    I'm thinking you like to type more then Me?......LOL..!!!!!
  • idbruceidbruce Posts: 6,197
    edited 2011-08-17 19:58
    Walt my friend

    C++ is so much more powerful :)

    I would never take a knife to a gun fight :)
Sign In or Register to comment.