Author Topic: Arduino Serial Read issue.  (Read 20874 times)

0 Members and 1 Guest are viewing this topic.

Offline PeterGTopic starter

  • Frequent Contributor
  • **
  • Posts: 835
  • Country: au
Re: Arduino Serial Read issue.
« Reply #25 on: March 27, 2012, 04:38:42 am »
Well, it looks like i may be a Delphi convert. Installed EX2 and it feels pretty good so far. The GUI is close to .NET.
Built a small form application and am impressed by there small footprint on the system. A lot smaller than any .NET based application.

Now i get to learn a whole new language. ;D ;D
Delphi looks like it wont be too hard to get my head around.

Thanks to Psi for pointing me in the right direction.

Regards
Testing one two three...
 

Online Psi

  • Super Contributor
  • ***
  • Posts: 10219
  • Country: nz
Re: Arduino Serial Read issue.
« Reply #26 on: March 27, 2012, 05:05:27 am »
Well, it looks like i may be a Delphi convert. Installed EX2 and it feels pretty good so far. The GUI is close to .NET.
Built a small form application and am impressed by there small footprint on the system. A lot smaller than any .NET based application.

Now i get to learn a whole new language. ;D ;D
Delphi looks like it wont be too hard to get my head around.

Thanks to Psi for pointing me in the right direction.

Regards

No problem :)

There's an option which sets if you want your application forms to be separate windows or part of delphi IDE.  (While developing)
The default on Delphi XE1 is to be part of the IDE (which i hate).
If you want to change it and can't figure out how let me know and i'll find the option.
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4303
  • Country: us
Re: Arduino Serial Read issue.
« Reply #27 on: March 27, 2012, 05:07:49 am »
Perhaps also "REAL Studio" (http://www.realsoftware.com/realstudio/ ) ?  I haven't used either it or VS enough to compare them, but it is a cross-platform "gui" style development system.  IIRC, it's BASIC, though the current web page looks like they're trying to de-emphasize that...
 

Offline PeterGTopic starter

  • Frequent Contributor
  • **
  • Posts: 835
  • Country: au
Re: Arduino Serial Read issue.
« Reply #28 on: March 27, 2012, 06:24:27 am »
I looked at Real Studio a while back. It only took a couple of hours before i uninstalled it.

I have been looking at Delphi this afternoon and dont seem to be able to find a control for Serial Port communication.
Does Delphi have a native control or do people usually roll there own?

Regards
Testing one two three...
 

Offline Teknotronix

  • Regular Contributor
  • *
  • Posts: 146
  • Country: au
Re: Arduino Serial Read issue.
« Reply #29 on: March 27, 2012, 06:48:08 am »
I looked at Real Studio a while back. It only took a couple of hours before i uninstalled it.

I have been looking at Delphi this afternoon and dont seem to be able to find a control for Serial Port communication.
Does Delphi have a native control or do people usually roll there own?

Regards

http://sourceforge.net/projects/comport/
Don't drone me bro!

 

Online Psi

  • Super Contributor
  • ***
  • Posts: 10219
  • Country: nz
Re: Arduino Serial Read issue.
« Reply #30 on: March 27, 2012, 07:07:48 am »
I have been looking at Delphi this afternoon and dont seem to be able to find a control for Serial Port communication.
Does Delphi have a native control or do people usually roll there own?
http://sourceforge.net/projects/comport/

yep, that's the one.  Tcomport is what i use as well.

I just installed it into Delphi XE1 right now  (i usually uses Delphi 7)
This should also work for Delphi XE2

Tcomport is a bit strange in its installation compared to other Delphi components.
It has a designetime and runtime package to install. but its not hard to do.


Here is how i installed it.

Download the TComport component and extract the zip to a location where you want to store 3rd party components. It's best if this isn't part of the Delphi directory.   i use d:\profile\programming\delphicomponents\tcomport\   


Installing the runtime package
- file - open - cportlibdxe.dpk  (its in the source folder of the stuff you unzipped)
- Rightclick on the CPortLibDXE.bpl entry in the delphi project manager and select compile
- Now you need to add that 'source' folder to the delphi library source list
   - click - tools - options
   - Select Environment options - delphi options - library
   - Click the button for library path
   - Click the yellow folder icon and select the source folder for Tcomport
   - Click Add and then ok

Installing the designtime package
- Click File - Open DsgnCPortDXE.dpk
- Rightclick on the DsgnCPortDXE.BPL entry in the project manager and select COMPILE
- Now Rightclick on the DsgnCPortDXE.BPL entry again and select INSTALL
- Your finished. click - File - Close all (don't have to save)

Now you should have the components installed.
You can create a new project and the Tcomport components should be in the component pallet.

Project - add new project - VCL forms application

-Drop a Tcomport on your form
-Set its comport to com1 (or whatever) and the bitrate to what you want.
-Set its connected property to true.
-Add a button that does   
Code: [Select]
comport1.transmitchar(  chr(50) );   chr(50) just converts 50 from a number to a character
There are a few other ways to send data in buffers and stuff for more advanced applications but TransmitChar() is good to just get stuff working quickly.

Run your program and when you click the button it should send one byte over the serial port


To read data you can use the RxChar event for Tcomport.

an event handler might look like this

Code: [Select]
procedure TForm1.ComPort1RxChar(Sender: TObject; Count: Integer);
var
   Str: String;
begin
   ComPort1.ReadStr(Str, Count); // read count number of bytes into the string str
   memo1.text := memo1.text + str;  // append data to a Tmemo. (You might want to convert it to hex though otherwise any ascii commands like
                                                     // tab or new line etc.. will cause that to happen on the memo.
end;
« Last Edit: March 27, 2012, 07:21:10 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline Teknotronix

  • Regular Contributor
  • *
  • Posts: 146
  • Country: au
Re: Arduino Serial Read issue.
« Reply #31 on: March 27, 2012, 07:16:13 am »
Great to see some delphi stuff on here.

A tip for the beginners looking at this thread. Unlike some other languages like C#, there are two features (among many) that I find very powerful for writing nice clean and readable code. They are "with" statements and nested functions. Try them out, they are great.
Don't drone me bro!

 

Offline PeterGTopic starter

  • Frequent Contributor
  • **
  • Posts: 835
  • Country: au
Re: Arduino Serial Read issue.
« Reply #32 on: March 27, 2012, 07:27:33 am »
Great to see some delphi stuff on here.

A tip for the beginners looking at this thread. Unlike some other languages like C#, there are two features (among many) that I find very powerful for writing nice clean and readable code. They are "with" statements and nested functions. Try them out, they are great.

now that i am starting out with Delphi, i can guarantee there will be more Delphi threads on here for a while at least... ;D ;D ;D

Thanks for the help people.

Regards
Testing one two three...
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf