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

Get data from Notepad into Propeller

24

Comments

  • $WMc%$WMc% Posts: 1,884
    edited 2011-08-17 20:00
    PhiPi
    '
    What OS are you using????
  • idbruceidbruce Posts: 6,197
    edited 2011-08-17 20:01
    I have the old XP, but I prefer it to Vista or 7

    Ooopss that was for Phil. Sorry
  • $WMc%$WMc% Posts: 1,884
    edited 2011-08-17 20:05
    Bruce
    '
    PC code
    '
    or Prop code
  • idbruceidbruce Posts: 6,197
    edited 2011-08-17 20:07
    Walt

    PC code. I still have not gotten around to experimenting with C on the Prop just yet. And I probably won't. I will get into PASM or that one you suggested.
  • $WMc%$WMc% Posts: 1,884
    edited 2011-08-17 20:10
    Bruce:
    '
    I was talking about Prop code.
  • idbruceidbruce Posts: 6,197
    edited 2011-08-17 20:18
    Walt

    Ah ha I see. As it applies to this problem, I do not believe the problem lies on the Prop side, but on the PC side. So I am examining serial port programming on the PC side of things. More particularly, I am examining the possibilities of posts 20 and 21. I think it would be nice to be able to read values from a PC file and write values to PC file as designated by the Propeller chip.

    Bruce
  • idbruceidbruce Posts: 6,197
    edited 2011-08-17 20:21
    Walt

    For example, you could even have the Prop creating files on the PC and then write values to this file, for example a csv file, which could then be opened in excel and printed in tables or such.
  • idbruceidbruce Posts: 6,197
    edited 2011-08-17 20:27
    Walt

    You could even have data coming into the PC from the Prop and updating values on a website. The main thing is the communication, and I have all the code in front of me. The user interface, file writing, file reading, and miscellaneous code is just trivial once you have the communication down,
  • kochevnikkochevnik Posts: 30
    edited 2011-08-17 20:29
    For what it is worth - you do not need any kind of activex or dll object to send data via serial port to your propeller on Windoze. You can do this in pretty much any windows program which can call the windows API. I spent a fair amount of time looking at $300 active X objects before I found a link to some PB code a guy in Thailand built :

    http://talent.in.th/software/comm.pbl/index.shtml

    Basically you call a series of windows API functions and these open the com port, set it up for use, write/send data read/receive data and close the port. For example you call these windows API functions to open the port :

    CreateFileA
    GetCommState
    BuildCommDCBA
    SetCommState
    then set a bunch of values in a structure.

    For the OP - if you are not going to write a computer program to send the notepad file, then you will need some kind of serial terminal program to do this. I think there are a lot of them out there, but for me, I think writing a program is a much better way to send the data, no matter what windows language you use.
  • $WMc%$WMc% Posts: 1,884
    edited 2011-08-17 20:33
    Bruce
    '
    Yes
    '
    Know you see it.
  • idbruceidbruce Posts: 6,197
    edited 2011-08-17 20:33
    kochevnik

    For Visual C++, here is a link to some very impressive serial port programming code. With this code and a little C++ knowledge, there can be a wide diversity of new applications for the Propeller interfacing with a PC.

    http://www.codeproject.com/KB/system/serial.aspx

    Bruce
  • $WMc%$WMc% Posts: 1,884
    edited 2011-08-17 20:40
    kochevnik wrote: »
    For what it is worth - you do not need any kind of activex or dll object to send data via serial port to your propeller on Windoze. You can do this in pretty much any windows program which can call the windows API. I spent a fair amount of time looking at $300 active X objects before I found a link to some PB code a guy in Thailand built :

    http://talent.in.th/software/comm.pbl/index.shtml

    Basically you call a series of windows API functions and these open the com port, set it up for use, write/send data read/receive data and close the port. For example you call these windows API functions to open the port :

    CreateFileA
    GetCommState
    BuildCommDCBA
    SetCommState
    then set a bunch of values in a structure.

    For the OP - if you are not going to write a computer program to send the notepad file, then you will need some kind of serial terminal program to do this. I think there are a lot of them out there, but for me, I think writing a program is a much better way to send the data, no matter what windows language you use.
    '
    Thanks for the info....
  • idbruceidbruce Posts: 6,197
    edited 2011-08-17 20:51
    I am just surprised that this is not a big topic in the Propeller forum already. There are an enormous amount of possibilites. Once you have communication and listening programs, you have access to a whole computer and the internet.

    Bruce

    EDIT: Not to mention, telephones, faxes, lighting, security, etc...
  • kochevnikkochevnik Posts: 30
    edited 2011-08-17 20:57
    Bruce : absolutely. I'm working on a system that will control pretty much most everything on my property from my PC's thru propellers. Once you have a good communications channel between the props and a PC there are a LOT of cool things you can do with it. Throw in things like mobile phones communicating with the PC and you can control anything from anywhere.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-08-17 20:58
    @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.

    You should also be able to use a Prop Plug without connecting the reset line.

    Someone suggested in the other thread very similar to this one to use the file command to load the data in at compile time.

    Duane
  • idbruceidbruce Posts: 6,197
    edited 2011-08-17 21:08
    kochevnik

    However, creating the PC listening programs would be the hard part for most people. That is probably why it is not a big topic.

    Bruce
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-08-17 22:58
    Hi Everyone
    are you aware that you hi-jacked zpua's thread massively?

    to get back on zpua's question:

    Yes the method of using excel to create the DAT-section is right.
    But there are bugs in the syntax.

    the word "long" means the following source-code-characters are interpreted as signed 32bit values

    This means the numbers can vary from -2^31 to +2^31

    +-2^31 is +-2_147_483_648.

    examples
    DAT
    MyData
      long 100
      long 8
      long 527
      long 569
    

    or
    DAT
    MyBigValues
      long    -10_980_000
      long     20_560_134
      long -1_789_233_120
      long    345_720_845
    

    floating-point values are not directly possible. Integervalues are always numbers without decimal-point.

    You have 9 digits behind the decimal-point. Do you really need a precision of 9 digits?
    Are you measuring values with the propeller? Even if you are using a 24bit ADC the values result in 8 decimal digit-values.

    Your attached code compiles but does nothing senseful. From what you have coded I can clearly conclude that you are a beginner.
    That is really OK. But please do me a favor and post a detailed description of what you want to do in the end?

    Comparing values is not a selfpurpose. With doing in the end I mean the global overview. If your project is absolutly finished what does it do?
    Do you create a soft-ice selling robot?
    Do you create a component quality checker?

    I don't know. But this is the most important information to find a suitable solution.

    If you keep this a secret I will stop supporting you. It might be that there are good reasons to keep it a secret, so that ,I if I would be in your position would keep it a secret too.
    But if you don't mind please post what you want to do in the end.

    A good solution highly depends on what you want to do in the end

    keep the detailed descriptions coming
    best regards

    Stefan
  • idbruceidbruce Posts: 6,197
    edited 2011-08-18 04:37
    Hijacked? Although it definitely appears that way, I don't think so. Even though my posts are not particularly directed at him, they do offer a solution. To accomplish the stated task, some serial port listening program with file reading capabilities must be used. Even if you use some type of printer port configuration as Phil suggests, it is still listening, and the ultimate goal is to read values from files. And since I am seriously seeking a solution here, why not list the other possibilities.

    Stefan, since you mention hijacking.... how does your last post apply to the problem at hand. I don't see one piece of information in it that gets us closer to a solution of getting data from Notepad into the Propeller. I see programming hints which is great and useful, but no where near the topic of solving the problem as stated.
    Someone suggested in the other thread very similar to this one to use the file command to load the data in at compile time.

    That was my suggestion. Thanks for the plug Duane. If it is not going to be a real time solution using a software listening program on the PC side, the FILE directive is the easiest possible solution, and if it needs to be a real time solution, then you will need the proper software on the PC side. So I believe I am right on target :)


    EDIT:
    A good solution highly depends on what you want to do in the end

    The main question is: Does he need a real time solution, or can the data be compiled?
  • idbruceidbruce Posts: 6,197
    edited 2011-08-18 05:52
    There is another possible real time solution, but it also involves software on the PC side.
    1. Open the desired file on the PC, read the values into variables.
    2. Enumerate all visible windows on a Windows operating system, looking for the caption : "Parallax Serial Terminal". When this window is found, the software could enumerate the child windows until the class "TMemo" is found, then grab the Window handle and set the window text to first value and simulate the pressing of the ENTER key on the keyboard. Then iterate through the remaining values.
    I don't particularly like this scenario, but it is a possibility.

    Bruce
  • zpuazpua Posts: 33
    edited 2011-08-18 09:31
    Stefan,

    I have mentioned many times, what I want to do is just to compare the data. Since you can see that I am a beginner, my instructor just ask me to practice on how to send data into propeller. That's it.
    I really do not have anything to hide. My ultimate purpose really just need to send data into the propeller and read by propeller, then I am done with the task that asked by my instructor. Thats's why I really need help for my syntax for using File command. Please lend me a hand.

    Bruce,

    Thanks for your help, but sadly, I can't understand what you mean. Do you mind to help me work the file command code? Thanks
  • PliersPliers Posts: 280
    edited 2011-08-18 09:36
    Zpua, what version of windows are you using?
  • zpuazpua Posts: 33
    edited 2011-08-18 09:39
    Pliers,

    I am using window 7.

    zpua
  • idbruceidbruce Posts: 6,197
    edited 2011-08-18 10:47
    zpua

    Yes, I will help, but give me until the end of the day, because I have some other things to do. I have already worked on it a little. You need to start out simple and then work to something more complex. So we will start of with one value in a file and our example will be very similar to the FILE directive example given in the Propeller Manual. Additonally, I have no spare Propeller boards to test my code, but I may figure something out for this.

    Here is a good starting point for you.
    CON
     
      _CLKMODE      = XTAL1 + PLL16X
      _XINFREQ      = 5_000_000
     
    DAT
     
      Data          FILE      "DataFile.dat"
      Str byte 0 'If this file is not NULL terminated, we need to add a 0
     
    OBJ
     
      Debug:"FullDuplexSerial"
     
    VAR
     
      LONG DataValueOne
     
    PUB GetData | Index, Temp
     
      Debug.Start(31, 30, 0, 115_200)
      WAITCNT(CLKFREQ * 2+ CNT)
      Debug.Tx(Debug#CLS)
     
      Index := 0
     
      REPEAT
     
        Temp := BYTE[Data][Index++]  'This is an individual character
     
        'Do something with this character, get this character from
        'Temp into DataValueOne 
     
        'Try figuring this out until I can spend more time on it 
     
      WHILE Temp > 0
     
      Debug.Dec(DataValueOne)
    
  • David BDavid B Posts: 592
    edited 2011-08-18 11:04
    Does "send data to the propeller" include "over a serial connection" as part of the requirement?

    You could write the file to an SD card on the PC, move the card to the prop, then read from the card.

    That would, strictly speaking, "send data into the propeller and read by propeller".
  • zpuazpua Posts: 33
    edited 2011-08-18 11:31
    Bruce,
    Thanks, will catch you at the end of the day. :)

    David,
    That's a way but I do not have the port on my board for me to insert a SD card. So it can't work for me. Thanks, btw.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-08-18 11:55
    zpua,

    What is your Propeller setup? Do you have a Prop Proto Board? Does it use a Prop Plug or is it a USB Protoboard.

    Does your computer have a serial port (RS-232 not USB)?

    I think Bruce's file idea would be the easiest method but not the most versatile method.

    Bruce's and other's idea of having an application running on the PC to send the data would be the most versatile.

    Phil's "print file" idea is a nice middle ground. This is why I ask about the connections on your Propeller board and your computer. There may be a relatively easy way around the reset problem.

    Duane
  • zpuazpua Posts: 33
    edited 2011-08-18 12:22
    Duane,

    I am just using a demo board and USB port. Since I am a beginner, Bruce's File idea is the only way I can make sense of. It does not matter if it is not versatile, it would be a good practice for me.
    Thanks.
  • idbruceidbruce Posts: 6,197
    edited 2011-08-18 12:28
    zpua

    Like I said, I do not have anything to test this code, but I think it should work. If there is something wrong with it, I am sure someone will gladly point it out. :)

    Bruce
    CON
     
      _CLKMODE      = XTAL1 + PLL16X
      _XINFREQ      = 5_000_000
     
    DAT
     
      Data          FILE      "DataFile.dat"
      Str byte 0 'If this file is not NULL terminated, we need to add a 0
     
    OBJ
     
      Debug:"FullDuplexSerial"
     
    VAR
     
      LONG DataValueOne
      BYTE DataFileCharacter[1]
     
    PUB GetDataAndCompare | Index, ComparisonValue
     
      ComparisonValue := 2_147_483_647 'Maximum value for LONG type declarations
     
      Debug.Start(31, 30, 0, 115_200)
      WAITCNT(CLKFREQ * 2 + CNT)
      Debug.Tx(Debug#CLS)
     
      Index := 0
     
      REPEAT
     
        DataFileCharacter[0] := BYTE[Data][Index++]  'This is an individual character
     
        DataValueOne := DataValueOne * 10 + (DataFileCharacter[0] - "0") 
     
      WHILE Temp > 0
     
      Debug.Dec(ComparisonValue)
      Debug.Tx(13) {Carriage Return} 
      Debug.Dec(DataValueOne)
      Debug.Tx(13) {Carriage Return}
     
      IF DataValueOne == ComparisonValue
     
        Debug.Str(STRING("These values are equal"))
     
      ELSE
     
        Debug.Str(STRING("These values are unequal"))
    
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-08-18 12:41
    As it turns out, Bean's idea is a winner. Here's a screenshot that shows my test program and the DOS procedure:

    attachment.php?attachmentid=84223&d=1313696456

    It's important to use the mode command to set things as shown. And you have to reissue the mode command after each program upload from the Propeller Tool, because the baud rate reverts to 115200 -- at least on my PC. Also, with the mode command, you have to set all the parameters that differ from their default values every time you call it; otherwise the unspecified parameters are reset to their default values.

    BTW, to read numbers as numbers, it's simpler to use FullDuplexSerialPlus.

    -Phil
    685 x 661 - 17K
  • idbruceidbruce Posts: 6,197
    edited 2011-08-18 12:49
    Great :( Now I have to read everything all over again to understand just exactly what you accomplished.
Sign In or Register to comment.