Shop OBEX P1 Docs P2 Docs Learn Events
Writing Visual Basic 2008 programs that interact with a Propeller — Parallax Forums

Writing Visual Basic 2008 programs that interact with a Propeller

MicrocontrolledMicrocontrolled Posts: 2,461
edited 2010-02-12 02:40 in Propeller 1
I have been reading through a book on writing Visual Basic programs and was wondering if anyone else had any experiance with writing Visual Basic 2008 programs that interact with a propeller for gathering data, sending data, loading in a SPIN program, etc. Any comments or advice on how to do it allong with a sample program would be nice.

Thanks,
Micro

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Computers are microcontrolled.

Robots are microcontrolled.
I am microcontrolled.

SX Spinning light display·

http://designedbymemicros.blogspot.com/

Comments

  • Jim FouchJim Fouch Posts: 395
    edited 2010-02-07 18:40
    I created a recent project for one of my clients that was designed to control 4 120V AC circuits. I used a Prop Proto board, XBee modules so the PC & Control box could be far apart.

    I created a control program in VB.Net 2008 that gave the user an easy to use front end. I used the build in SerialPort object in VB. It was a pretty simple project and is running as we speak to do unit testing (test power failures) for a larger application I wrote.

    It recently ran for 3 weeks interrupting the power to various machines and testing the robustness of the main application software.

    One of the things with using the serial Port object in VB is you need to have basic understanding of multi-threading to support the characters coming back from the port. It's not too hard.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jim Fouch

    FOUCH SOFTWARE
  • jazzedjazzed Posts: 11,803
    edited 2010-02-07 18:56
    Events and Delegates handle the multi-threading aspects of .net drivers.
    Edit: Rest of post canceled due to lack of interest.

    Post Edited (jazzed) : 2/7/2010 8:20:51 PM GMT
  • localrogerlocalroger Posts: 3,452
    edited 2010-02-07 19:04
    I've done lots of that sort of thing. In the short time I've been working with the Prop, trying to develop what will become my core toolset, I keep running into things that can be done so much more easily and cheaply just with stuff from the obex that nothing else makes sense.

    I work mostly in VB6 because I have a lot of personal legacy code, much of it coded straight to the API so it doesn't play well with vb.net. I have tools for going to serial ports and TCP/IP without using plugins, which means that my .exe's have only the vbrun600 dll dependency, and that's been present on every PC I've taken delivery of since 2002. That means you can just copy the .exe into a folder and run it, without running an installer. Makes backing up and restoring a hell of a lot simpler.

    Your main comm channel will be serial, either through a real serial port or the FTDI usb converters. The trick is to remember all external comms are unreliable and remember to deal gracefully with missing or garbled data. This means making sure your receive buffers don't overrun if you don't get the terminating character you expect and re-trying comms that are timing out. Generally you need to decide that one device, either the PC or the Prop, will drive comms and let it do timeouts and retransmit requests; the other device will be quiet if it's never queried. There are a million ways of doing this with different strengths depending on what kind of data you are sharing; recording the occasional weighment is a lot different from streaming audio.
  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2010-02-07 19:20
    Thanks. I have been reading an article on interfacing a PC to microcontrollers in N&V lately and that is what gave me the idea. Thanks for all the help so far.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Computers are microcontrolled.

    Robots are microcontrolled.
    I am microcontrolled.

    SX Spinning light display·

    http://designedbymemicros.blogspot.com/
  • fullspecengfullspeceng Posts: 76
    edited 2010-02-09 02:40
    If you're using an USB bus, look at FTDI's examples for VB: http://www.ftdichip.com/Projects/CodeExamples/VB.htm

    It's everything you need and more.

    That said, I think the C# examples make a lot more sense: http://www.ftdichip.com/Projects/CodeExamples/CSharp.htm

    The FTDI .NET wrapper is excellent.
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2010-02-09 03:22
    @ microcontrolled

    FTDI - D2XX Programmer's Guide 1.02 Lists functions available in FTD2XX.DLL

    www.ftdichip.com/Documents/ProgramGuides/D2XX_Programmer%27s_Guide%28FT_000071%29.pdf
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-02-09 04:04
    I wrote one to talk to a picaxe www.instructables.com/id/Control-real-world-devices-with-your-PC/ step 8 has some code in vb.net. Very similar building blocks - how to open serial ports, change baud rates etc.

    If you feel really keen you can join the N8VEM group and get access to a more complete program I wrote that has a VT100 terminal, xmodem file transfers.

    Start simple though. A few buttons and text boxes, make a loopback cable by joining pins 2 to 3 on a D9 and see if you can send a byte and then read it back again.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.smarthome.viviti.com/propeller
  • Brian_BBrian_B Posts: 842
    edited 2010-02-09 04:23
    Micro,
    Here is a basic program that I have used as a template to talk to the propeller.

    http://www.serialporttool.com/NCD/R8X_VB2008.htm


    Brian

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔





    "Imagination is more important than knowledge..." Albert Einstein
  • Agent420Agent420 Posts: 439
    edited 2010-02-09 11:34
    FWIW, you can use the Ring and Carrier Detect lines from the serial port as event driven IO input, and the DTR and DSR lines as generic outputs in VS 2008.· This gives you 2+2 I/O from any generic serial port, great for small control apps.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2010-02-09 19:13
    Thanks!!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Computers are microcontrolled.

    Robots are microcontrolled.
    I am microcontrolled.

    SX Spinning light display·

    http://designedbymemicros.blogspot.com/
  • VIRANDVIRAND Posts: 656
    edited 2010-02-10 08:15
    This is going to sound ridiculous, but where's the OP answer?
    in 1980, Microsoft BASIC would be the first thing you would see when
    you turn on virtually any brand of computer.
    In 1990, You had to Boot a disk, then type GWBASIC or QBASIC or just BASIC.

    Now, after reading this thread, I apparently missed what you do to get to Visual BASIC or VB.NET
    on a PC, which must be black magic, because it is the topic of the thread, and I have not now nor ever
    seen the answer, yet someone is satisfied at having received it!
    http://VB.NET --- what IS this? --- Seriously!!!

    My friend's BSoD'd computer is back, fresh and like new.
    Here I have a lot of BASIC computers. Given 5 minutes, I may be able to turn them ALL on,
    and type in and RUN a HELLO WORLD program on almost all of them.

    I challenge ask anyone to please tell me how to do that on this one freshly fixed PC. (Oops). blush.gif

    15 Minutes, to turn on that PC and write and RUN a BASIC program to send HELLO WORLD to a Propeller!
    I am now daydreaming of doing a video documentary about this teeny tiny task,
    which has been invisibly answered here, and which I have not groked for the past decade!
    Within my arms reach, I have a laptop with 1983 Microsoft BASIC that can be turned on and programmed
    to send HELLO WORLD to a Propeller to be displayed on its monitor in 15 Seconds.

    After almost 2 or 3 decades,
    Why can't I, nor any of my friends, ever figure out how to program Windows PCs?
    So, how do you program Visual BASIC... to use the Propeller... or do anything?
    How long will it take? 15 seconds, minutes, hours, days, months, years?

    Finally ... a thread with an answer! ...but... Where?
    Please reply with the nice quick HELLO WORLD demo code in a nice one-line code block,
    and what to click on get READY to type it in!


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I should be typing in Spin now.
    Coming soon. My open Propeller Project Pages and favorite links index.

    Post Edited (VIRAND) : 2/10/2010 9:59:24 AM GMT
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-02-10 09:47
    Ha ha Virand. Yes, of course many bits are glossed over. The Instructable link I posted takes you through the steps to get vb.net, and hidden in that is the fact you do need to do an 80Mb download from Microsoft, and then install vb.net. It can take half an hour or more. But it is a free program and the older vb6 isn't.

    And if you are going to go to all that bother, why not install c dot net and java dot net as well?

    Anyway, I digress. The picaxe example shows how to send a couple of bytes out of a serial port and get a few bytes back. At the propeller end, you are going to need a max232 and a serial port object and some glue code and then it won't work so you need some way of debugging it, but you can't debug using the serial port because you are already using that, so you need a different way of debugging it, so why not add a vga screen and then you may as well add a keyboard, and heck, you probably need an sd card and an operating system...

    Sersiouly, it does take a lot of work to make it all come together easily. And I haven't mentioned a more complete IDE environment I've written in vb.net which has a VT100 terminal and can do xmodem file transfers to the propeller but best to do this with baby steps first.

    But when it is all working it is very quick and simple. I can fire up a vb.net program on a PC in about 20 seconds, and a propeller dracblade board, and have basic running on that propeller board within a few seconds. Or do that without even needing the PC.

    Re "I have a laptop with 1983 Microsoft BASIC that can be turned on and programmed
    to send HELLO WORLD to a Propeller to be displayed on its monitor in 15 Seconds."

    I just timed that on the propeller dracblade. 23 seconds from bootup to running basic to printing "Hello world". I'm impressed with 15 secs - you must be a fast typist!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.smarthome.viviti.com/propeller
  • VIRANDVIRAND Posts: 656
    edited 2010-02-10 10:18
    Are c.net and java.net the right URL's? I'll guess not and ask: Why NOT?
    I think my 15 second code would look something like:
    (Power on)
    READY
    10 OPEN COM:9600,8,N,1 FOR OUTPUT AS #1:PRINT #1,"Hello World"
    RUN
    (done, after preloading a propeller terminal into Propeller)
    I'm wasting time, and off topic. OK. So there's 80 megs of stuff to download for Visual Basic.
    It sounds like lifetimes wasted on Millions of lines of code, needing lifetimes more to make it work,
    before it expires like a carton of milk, and gets replaced by a much bigger one.

    Post Edited (VIRAND) : 2/10/2010 11:29:38 AM GMT
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2010-02-10 11:30
    VIRAND,

    "dot net" is a framework not a url. It allows you to write code in a variety of programming languages that will all work the same within the .net frame work. The programmer downloads the IDE (that is the 80mb part) and writes a program. The user runs the program only he must have the .net framework installed on his machine. It is a little like having the java runtime engine running on your machine in order to run java stuff.

    Remember that VB lets you create software with GUIs as well as console type apps, that is why it is big, you are downloading an IDE and an interface designer etc. XP is not based on MsDOS so no qbasic though I read you can get it off an Windows Me CD and run it in emulation mode.

    It is hard to say if you are actually interested to know the details (you could have just used wikipedia) or if you just want to complain about microsoft and the way things are going. I would not disagree with you really, in my job I was forced into having to write some visual C++ code with MFC, I really hated it, then I looked at the .net framework and decided I wanted out of it all. I'm currently (while I sit here) learning Python and QT and perhaps when I get around to it I will bow out of windows too.

    Oh if you have excel it is possible to develop VB code inside it.

    Graham
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-02-10 11:43
    Ok VIRAND, sorry, www.microsoft.com/express/Downloads/

    To me .net is a fusion of C#, C++, Basic, and Java and it seems to be heading in a direction that is good for all the languages. It might even end up being a solution to the "my language is better than yours" arguments that have been going for so many decades. Certainly as a Basic Programmer I'm using more and more C (which you can do in vb.net), and there are even code fragments for vb.net and C#.net that end up almost the same.

    as for the propeller, my 23 second code is:
    A>MBASIC
    
    BASIC-80 Rev. 5.21
    [noparse][[/noparse]CP/M Version]
    Copyright 1977-1981 (C) by Microsoft
    Created: 28-Jul-81
    32824 Bytes free
    Ok
    10 PRINT "Hello World"
    RUN
    Hello World
    Ok
    
    


    And I could cheat and compile that and turn it into HELLO.COM and then put HELLO.COM as a single line in a file called AUTOEXEC.SUB and then reboot and I wouldn't have to type anything and it would be only 12 seconds. (But of course, you could write a Spin program and do it in 2 seconds!)

    Maybe vb.net isn't the smallest but it was the program our OP wanted, and it happens to be the program I've used to write practice management software for medical practices, and if you total up the money that has gone through the free installations of that program over the last few years it comes to several million dollars (I gave it away to my local community hospital for free) It may not be the fastest and it certainly is not the smallest to install, but, like spin, it has a vast library of free code and objects already written eg www.planet-source-code.com/ So a lot of coding ends up 'cut and paste'.

    So, for Microcontrolled, I'd be more than happy to take you through the steps from outputting a single byte to getting a fully fledged program working that can talk in an interactive way with a propeller. I'm actually coding something similar at the moment with bytes starting off in vb.net and going to a propeller and then being routed wirelessly between other propellers.

    As for some real vb.net code
    Imports System.IO
    Public Class frmMain
        Dim WithEvents SerialPort As New IO.Ports.SerialPort ' serial port declare
    
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                SerialPort.ReadTimeout = 100
                SerialPort.PortName = "COM1"
                SerialPort.BaudRate = "38400" ' 38400
                SerialPort.Parity = IO.Ports.Parity.None ' no parity
                SerialPort.DataBits = 8 ' 8 bits
                SerialPort.StopBits = IO.Ports.StopBits.One ' one stop bit
                SerialPort.ReadTimeout = 1000 ' milliseconds so times out in 1 second if no response
                SerialPort.Open() ' open the port
                SerialPort.DiscardInBuffer() ' clear the input buffer
                SerialPort.Write("Hello World")
                SerialPort.Close()
    End Sub
    
    


    and you would find it a lot easier to draw a simple form on the screen with a button and run this when you push the button, though this code runs automatically when the main form1 is loaded.

    There are better ways to do this, eg outputting bytes one at a time from a byte array rather than from strings as vb.net won't send out raw bytes from 128 to 255, but this is a simple demo that prints something to a com port. If that works we can move on to reading some bytes back.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.smarthome.viviti.com/propeller

    Post Edited (Dr_Acula) : 2/10/2010 12:34:20 PM GMT
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-02-10 14:13
    Computers have progressed so much over the last 30 years...

    From this complex stuff
    10 PRINT "Hello World"
    RUN
    
    

    To something simple like this
    Imports System.IO
    Public Class frmMain
        Dim WithEvents SerialPort As New IO.Ports.SerialPort ' serial port declare
    
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                SerialPort.ReadTimeout = 100
                SerialPort.PortName = "COM1"
                SerialPort.BaudRate = "38400" ' 38400
                SerialPort.Parity = IO.Ports.Parity.None ' no parity
                SerialPort.DataBits = 8 ' 8 bits
                SerialPort.StopBits = IO.Ports.StopBits.One ' one stop bit
                SerialPort.ReadTimeout = 1000 ' milliseconds so times out in 1 second if no response
                SerialPort.Open() ' open the port
                SerialPort.DiscardInBuffer() ' clear the input buffer
                SerialPort.Write("Hello World")
                SerialPort.Close()
    End Sub
    
    

    LOL

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
    · Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
  • BradCBradC Posts: 2,601
    edited 2010-02-10 14:24
    Program Hello_World;
    Var
      Serial : Text;
    Begin
      Assign(Serial,'/dev/ttyUSB0');
      Rewrite(Serial);
      Writeln(Serial,'Hello world');
      Close(Serial);
    End.
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You only ever need two tools in life. If it moves and it shouldn't use Duct Tape. If it does not move and it should use WD40.
  • Agent420Agent420 Posts: 439
    edited 2010-02-10 15:48
    VIRAND - times change.· I suggest you accept that inevitable fact.·

    I am not the world's biggest fan of .NET, but there are many elements of·current Windows OS that would simply be impossible to address with the older versions of basic.

    So the download is 80 megs... are you on a diet?· You've never downloaded or installed a large program before?· Hey - at least it's free.

    If all you desire is the ability to produce a simple serial port code, nothing is preventing you from either setting up a·machine dedicated for that purpose.· Or set up a VM.·· You can get QuickBasic here: http://www.qbcafe.net/qbc/english/download/compiler/qbasic_compiler.shtml
    Cluso99 said...
    Computers have progressed so much over the last 30 years...
    ·LOL... true.·· But on the other side of the coin, you didn't have event driven code that could fire on a serial port pin change without constant polling.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Agent420Agent420 Posts: 439
    edited 2010-02-10 16:42
    VIRAND said...
    After almost 2 or 3 decades,
    Why can't I, nor any of my friends, ever figure out how to program Windows PCs?
    So, how do you program Visual BASIC... to use the Propeller... or do anything?
    How long will it take? 15 seconds, minutes, hours, days, months, years?
    Only you can answer that.· I would think that within the span of nearly 30 years, you'd be able to create a VB app.· It's not like it's some esoteric language; they are literally millions of code examples on the web.

    You've but only try.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-02-10 22:28
    LOL indeed Cluso. Though the difference isn't quite so much. For a pure output you can delete a few lines. And some lines can go because the defaults are 8 bits, one stop bit etc. You don't need a read timeout for just output. You don't need to clear the input buffer. So it could end up;
                SerialPort.PortName = "COM1"
                SerialPort.BaudRate = "38400" ' 38400
                SerialPort.Open() ' open the port
                SerialPort.Write("Hello World")
                SerialPort.Close()
    
    


    And if you chose to call an object in spin "SerialPort" and you chose to call the subroutines "Baudrate" and "Write" etc then I think the above might end up almost identical to Spin??

    I paid hard earned dollars for VB5 and then VB6, so I was pretty pleased when Microsoft decided to give away VB.NET.

    The above is a start. Then you can start wrapping "Hello World" in a packet - add a checksum at the end, put a few bytes on the front as a header so you can tell which board it is meant to go to. Maybe add an acknowledge byte and if that byte doesn't come back in a specified time then it flags a 'not communicating' error.

    Then there are the cool 'hidden' things vb.net can do - eg as mentioned above by agent420, , have event driven code. Or you can use .doevents where you tell windows to go off and do other things - this means the code doesn't slow down the rest of windows. I use that command liberally in my code, eg when reading in big text files which tends to tie up windows. Also for real world programming, rather than start with code, generally you start with a blank form, put some buttons and text boxes on the form, make it look good, and then start double clicking on the buttons which opens up the code view with the subroutine already pre-written. Then just add the code for the button.

    If you are a C programmer you could use the variants of C.NET on the PC side and Catalina on the Propeller and it would make the interface a lot easier as it wouldn't involve switching languages as you debug it.

    With Propbasic, maybe the same thing could be done with vb.net and propbasic.

    This makes me start thinking about a PC language called Spin.net

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.smarthome.viviti.com/propeller

    Post Edited (Dr_Acula) : 2/10/2010 10:40:40 PM GMT
  • VIRANDVIRAND Posts: 656
    edited 2010-02-11 10:06
    Agent420 said...
    VIRAND - times change. I suggest you accept that inevitable fact.

    I am not the world's biggest fan of .NET, but there are many elements of current Windows OS that would simply be impossible to address with the older versions of basic.
    Well that is why we sometimes use Assembler

    So the download is 80 megs... are you on a diet? You've never downloaded or installed a large program before? Hey - at least it's free.
    80 megs is 2.5x my Virtual Reality World, since the whole "universe" is 32MB. scool.gif
    Microsoft may be able to eat the world with 80 million bytes but yes I'm on a diet. burger.giflol.gif
    Especially if it takes 80MB instead of 8KB just to get "READY" to type Hello World!
    shocked.gif

    If all you desire is the ability to produce a simple serial port code, nothing is preventing you from either setting up a machine dedicated for that purpose. Or set up a VM. You can get QuickBasic here: http://www.qbcafe.net/qbc/english/download/compiler/qbasic_compiler.shtml
    Thanks; I already have QB 4.5; I wonder if there was a sequel.

    LOL... true. But on the other side of the coin, you didn't have event driven code that could fire on a serial port pin change without constant polling.
    (Didn't or Don't?) Um... in ASMx86 we always have interrupts that respond with minimum latency to port events.
    Is anything possible with 80MB of mystery and magic that is not possible with 80KB of ASM?
    Where's the "Progress"? All I know is that all the awesome stuff stopped working or slowed down shortly after Win95.
    Whenever something new comes out for PC, it is always something old from before Y2K. eyes.gif
    Like internetphone which was better than Skype in the 1990s.
    Scanimate and Lundy had nearly realtime animation in the 1970s and 1980s, so what's wrong with PIXAR? confused.gif
    You need to maintain escape velocity or you can't to space anymore in the future. roll.gif
    Propeller is faster than Windows, unless you can write a VGA driver that needs no video chips in VB dot NET.
    At beyond 2GHz clock, what's the problem? I asked the same thing when PCs clocked at 133MHz.
    Sinclair ZX80 and ZX81 did it with a Z-80 and glue logic, as did I better with the 8051.

    The problem is Bill Gates and I are both getting too old and fat to win any races. shakehead.gif
    Only the Propeller is fast enough to run my retro-futuristic software before all my original hardware dies. jumpin.gifskull.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I should be typing in Spin now.
    Coming soon. My open Propeller Project Pages and favorite links index.

    Post Edited (VIRAND) : 2/11/2010 10:11:15 AM GMT
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-02-11 10:48
    Hear Hear!

    I agree with all those statements. I might even add some more, eg
    Why does a PC need a 500W power supply to write a letter?
    Why can't my son copy files from one drive to another with Vista? (he needs "administrator privileges. Which he has)
    Why is my PC now taking over 3 minutes to turn on?

    And why, oh irony of ironies, does VB.NET decide to die on the one day I am trying to post to this forum a message saying how good it is??!!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.smarthome.viviti.com/propeller
  • Agent420Agent420 Posts: 439
    edited 2010-02-11 11:33
    VIRAND said...
    Thanks; I already have QB 4.5; I wonder if there was a sequel.
    Actually, there is.· QBasic 7.1 is also available from that link.· It includes several nice extras such as database and module linking that 4.5 did not have.· It is less well known because it was targeted to the 'professional' market, and also because VB came out shortly afterwards.

    We actually have some legacy apps running at our shop that were coded in QB7...· It is quite the change of mindset when I occasionally have to step through the code to rememebr why something isn't working (typically user input that buggers it up).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • 10gigbill10gigbill Posts: 79
    edited 2010-02-11 16:21
    I’ve been using VB5 to work with all my SX/B projects and hope to use it
    With the prop project now. It has served me well. I make exe files with
    VB5 and they are transportable to my customer. I was under the impression
    That the (free) .net would not allow you to make exe…?


    Bill
  • Agent420Agent420 Posts: 439
    edited 2010-02-11 17:01
    ^ Unlike some of their earlier free versions that were indeed limited to running in design mode only, the express editions are rather capable, primarily limiting data-oriented features like odbc, sql, crystal reports etc.· But you can compile conventional exe files.
    Wikipedia said...
    Visual Basic Express

    Despite the fact that it is a stripped-down version of Visual Studio, some improvements were made upon Visual Basic 2008 from Visual Basic 2005. Visual Basic 2008 Express includes the following improvements over Visual Basic 2005 Express:

    The Express Editions (2005 and 2008) mostly have the same following limitations:[noparse][[/noparse]3] (Specific 2008 Express editions limitations here[noparse][[/noparse]4])
    • No IDE support for databases other than SQL Server Express and Microsoft Access
    • No support for Web Applications with ASP.NET (this can instead be done with Visual Web Developer Express, though the non-Express version of Visual Studio allows both web and windows applications from the same IDE)
    • No support for developing for mobile devices (no templates or emulator)
    • No Crystal Reports
    • Fewer project templates (e.g. Windows services template, Excel Workbook template)
    • Limited options for debugging and breakpoints
    • No support for creating Windows Services (Can be gained through download of a project template)
    • No support for OpenMP
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2010-02-12 00:41
    I can't remember who posted the "Hello World" serial code, but thanks!! The book I am reading has nothing on serial ports and I will be able to refer to that code later!

    @VIRAND: PLEASE don't turn this into an opportunity to bash Windows. Yes, Vista is trash. Slow, it freezes, and I need to enter a password just to copy or move a file. But I was never around in the good ol' days of simple computers, and every computer I have ever used has taken at least 2 or 3 minutes to start up, so I don't know any better.
    If I want to make something, I should make it so that almost anyone can use it. This is why I am writing in VB.NET. If someone can point me to an OS that isn't too hard to use and boots in a few seconds then I will use it. HOWEVER, I don't want one of VIRANDs infamous Window's woes that he invades so many threads with. If he can offer good advice then good, but unless you are saying something that has to do with the subject on hand then please do not use this thread to complain. There is nothing anyone can do about it, so what is the point?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Computers are microcontrolled.

    Robots are microcontrolled.
    I am microcontrolled.

    SX Spinning light display·

    http://designedbymemicros.blogspot.com/
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-02-12 02:40
    Re
    >I was under the impression
    >That the (free) .net would not allow you to make exe…?

    Yes, good news, it can. Maybe the marketing people need to work on explaining it better. It doesn't make a .EXE as such, but rather creates a file called SETUP.EXE and there is an associated folder that goes with that. The end user needs to run SETUP and if .DLL files need to be installed it does all that automatically. On reinstalls, SETUP.EXE takes about 2 seconds to reinstall an update. I tend to bundle up the package as a .ZIP, though vb.net gives you a number of options, including publishing to a hard drive location or to the internet.

    @microcontrolleed, have you got a form yet and have you got buttons and text boxes, and are you at the stage of clicking a button and changing text in a text box?

    If so, try adding a timer. Set the delay to 1 second, put some code in the timer box and get it to print something different in a text box every second. If you are stuck with that then let me know.

    There are lots of ways to get input from a serial port and you can set it up to run code when bytes arrive.

    I've gone for one solution where a timer checks the serial port periodically
      Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            ' collect bytes from the serial port
            Timer1.Enabled = False
            Static TimerCounter As Integer
            If SerialPortFound = True Then
                Call ReadSerialPort()
            EndIf
            Timer1.Enabled = True
     End Sub
    
    



    I turn the timer off while it is doing things in case it takes to long and starts recursively calling itself.

    I read the bytes into an array rather than a string, so define an array at the beginning so it is common
    Public Class frmMain
        Dim InPacket(0 To 2000) As Byte ' strings like chr(255) won't go out so define as an array
    
    



    then read any bytes

     Sub ReadSerialPort()
            Dim BytesToRead As Integer '  may as well get in batches
            If SerialPortFound = True Then ' in case no port exists
                Do
                    If SerialPort.BytesToRead = 0 Then Exit Do ' no more bytes
                    BytesToRead = SerialPort.BytesToRead
                    If BytesToRead > 2000 Then BytesToRead = 2000
                    SerialPort.Read(InPacket, 0, BytesToRead) ' read in a packet
                Loop
        End Sub
    
    



    Any bugs let me know as I'm copying this from bigger code and deleting some bits.

    Oh yes, sorry, define
    Public SerialPortFound As Boolean = True
    in the common at the top as well.

    and give the user an error message if there is no serial port - put this code at the beginning when the main form loads
            Try
                ' set the portname and baudrate in the loadini subroutine
                SerialPort.PortName = "COM1"
                SerialPort.BaudRate = "38400" ' 38400
                SerialPort.Parity = IO.Ports.Parity.None ' no parity
                SerialPort.DataBits = 8 ' 8 bits
                SerialPort.StopBits = IO.Ports.StopBits.One ' one stop bit
                SerialPort.ReadTimeout = 1000 ' milliseconds so times out in 1 second if no response
                SerialPort.Open() ' open the port
                SerialPort.DiscardInBuffer() ' clear the input buffer
            Catch ex As Exception
                MsgBox("Error opening serial port - is another program using the selected COM port?")
                SerialPortFound = False
            End Try
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.smarthome.viviti.com/propeller

    Post Edited (Dr_Acula) : 2/12/2010 2:47:04 AM GMT
Sign In or Register to comment.