1 / 36

An IAMBIC Keyer in VB.NET

An IAMBIC Keyer in VB.NET. Dave Wade G4UGM. Aims of Talk. Provide Overview of VB Introduce key concepts Main components of VB Demonstrate a simple program Show more complex programs Show limitations Give pointers on where to go next. Origin of Basic.

clarke
Télécharger la présentation

An IAMBIC Keyer in VB.NET

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. An IAMBIC Keyer in VB.NET Dave Wade G4UGM

  2. Aims of Talk • Provide Overview of VB • Introduce key concepts • Main components of VB • Demonstrate a simple program • Show more complex programs • Show limitations • Give pointers on where to go next

  3. Origin of Basic • Invented at Dartmouth College in 1964 (Beginner's All Purpose Symbolic Instruction Code) • Simple, Easy to learn, • Can run on small computers • Pic Basic • Almost Universally implemented • From Mainframe to Micro • Don’t know of a computer without “basic”

  4. Visual Basic • Basic for Windows • but can write “command line programs” • Simplified Windows Programming • “Basic” works out what has been clicked etc. • Calls a “snippet” of code to handle it • Introduced Structured Constructs • Reduced use of “goto” • <and the more evil “come from”>

  5. Iteration Sequence Selection “Structured Programming” • Edsger Wybe Dijkstra • Dutch Computer Scientist • Showed that ANY program could be written using only three constructs:- • All have • One entry, One Exit

  6. Many Dialects in Windows • VBA – Visual Basic for Applicatons • Part of MS Office e.g. Excel, Word • Lets look at this! • Also in “Open Office” • + Other Applications • VB Script • “super” batch language • Also used in “Internet Explorer”

  7. VB.Net • Grown up “Basic” • Fully featured language • “.NET” is the “windows interface” • Used by all windows languages • Current Version is 2008 • Use 2005 – very similar • Special “Express” versions • Free download

  8. Compare with PIC assembler • Number of statements • PIC • 35 instructions • 1 data type • 1 statement = 1 machine instructions • VB.Net • 51 Statement Types • 36 Operators • 150 functions • 1 statement = multiple machine instructions • Probably over 1000 objects in the .Net framework

  9. Elements of Basic - Constants • Constants • Integer – int8, int16, int32 10, 12345, -54 • Floating Point - single, double 1.0, 1.123e-5, 1.6e+5 • String “Hi Dave” • Boolean • True,False • Object • Cover later

  10. Elements of Basic - Variables • A place to store (changing) data • Name (alphanumeric) • Identifies each variable • Usually chosen to reflect use • iCount, dCurrent, bOff • Type • Defines what it can hold • Match Constant Types • int, double, string, boolean • Value • 10,0.95,“Hi Dave”

  11. Elements of Basic - Statements • “Instructions to the computer” • Assignment “=“ • Performs a calculation • Sets a variable to the result • A=A+3 • Control (if, while, do, select, catch, call) • “control” how instructions are interpreted If A > 5 Then Msgbox(“too small”) End If • Data Declarations • Create Variables – Reserve Storage – Give it a name • Dim voltage As Double

  12. Elements of Basic - Routines • Functions and Subroutines • Groups of Statements • Used to perform common tasks • Modules • Groups of Related subroutines • Common Storage • Variables that are shared between routines

  13. “Objects” • Objects – a defined set of • Properties • Variables that can be set or tested • Methods • Functions that perfom and action on the object • Events • Functions called by the object when it wants something to be done • Everything in VB.NET is an OBJECT • .NET framework defines many object types

  14. Forms - The Visual Bit • The most important thing in Windows • The windows • The graphical forms designer. • Allows you to build a user interface • Can add a variety of elements • Radio Buttons • Check Boxes • Combo Boxes • Text Boxes • Command Buttons

  15. Sample User Interface

  16. Debugging • VB is an “Interpreted” language • Runs more slowly • Debugging can be easier • Debugging tools • Breakpoints • Immediate Window • Demo

  17. “IambicMorse” object SendDot KeyDown() IambicMorse SendDash KeyUp() NoDot CWSpeed CWPitch

  18. Morse Timing • All timing derived from “dot” • Dash = 3 x Dot • Element Space = Dot • Inter-character Space = Dash = 3 x Dot • Morse speed based on sending “PARIS” • Total Length = 50 Dots • So for 12 words/Minute • 12x50 Dots/Minute = 600 Dots/Minute • Dot = 60000/600 Ms = 100 Ms • For “W” wpm dot length = 60000/(w * 50) Ms

  19. Making a “Beep” • Every application has “Console” object • This has a “beep” method • Console.Beep (Freq, Duration) • Plays the sound of a beep of a specified frequency and duration through the console speaker. • Frequency in Hertz, Duration Milliseconds • Do Demo

  20. Code To Send Dot/Dash • Code for a Dot Console.Beep(cwPitch, CInt(60000 / (50 * cwSpeed))) • Code for a Dash Console.Beep(cwPitch, 3 * CInt(60000 / (50 * cwSpeed))) • Code for a Pause Threading.Thread.Sleep(CInt(60000 / (50 * cwSpeed))) • Now look at real code. • SMRCC2

  21. Look at real code • This “code” sends a “dot” + inter-element space. Public Sub Dot() RaiseEvent keydown() Console.Beep(cwPitch, CInt(60000 / (50 * cwSpeed))) RaiseEvent keyup() Threading.Thread.Sleep(CInt(60000 / (50 * cwSpeed))) Application.DoEvents() End Sub • Dash code is the same • Except seens a longer beep • NoDot code just sleeps • Used for AutoComplete logic .

  22. The “Real” Program • Main page

  23. The “Real” Program • Settings

  24. The “Real Program” • Send from box

  25. The “Real” Program • Module Definitions • Used to pass data between the routines • DotDown and DashDown • Current state of “paddles” • DotWas and DashWas • “Memories” • only cleared when a character sent

  26. Generating Morse • Program will accept input from • Paddle on RS232/Serial Port • Mouse when pointer is over the “send pad” • Mouse Input • Use left and right buttons • Only when mouse is over a special spot

  27. Morse from Mouse • Code Called when a button pressed If (e.Button = Windows.Forms.MouseButtons.Left) Then If ChkSwap.Checked Then DotDown = True DotWas = True Else DashWas = True DashDown = True End If End If • Duplicate for other button • When the button is released • clear the “DotDown” ONLY

  28. Sending Logic While DotDown Or DashDown Or DotWas Or While DotDown Or DashDown Or DotWas Or DashWas If DotWas Or DotDown Then keyer.Dot() DotWas = False End If If DashWas Or DashDown Then keyer.Dash() DashWas = False End If End While If ChkAuto.Checked Then keyer.NoDot() keyer.nodot() End If End While

  29. Interfacing a Real Key • I used a serial port • Because VB.NET has this built in • Use the “Control” lines • RTS used to drive the “Paddle Key” • DTR used to drive the “PTT” • CTS & DSR are inputs from Key • VB calls an “Event” when a line changes • Program then can set status

  30. The Real Code If (e.EventType = IO.Ports.SerialPinChange.CtsChanged) Then If MYPort.CtsHolding Then DotDown = True DotWas = True Else DotDown = False End If End If If (e.EventType = IO.Ports.SerialPinChange.DsrChanged) Then If MYPort.DsrHolding Then DashDown = True DashWas = True Else DashDown = False End If End If If ((Not Sending) And (DotDown Or DashDown)) Then SendTask = New Thread(AddressOf SendCw) SendTask.Start() End If

  31. Demo the Key

  32. SendByte Function • Need to convert letters to “morse” • Uses the Morse_Code(char) function • Returns a string for each character • “T” for “doT” • “H” for “dasH” • So for example:- • “S” => “TTT” • “O” => “HHH” • “P” => “THHT” • Special Symbols • + (AR) ! (AS); # (KN); $ or * (SK); • % (SN); & (KA); = (BT); @ (AA).+ • Can then send use the Morse Keyer object • Used by to send “F” keys and “text” box

  33. Preset Buttons • Send Preset Strings • Stored in settings • Both caption and text can be set • Can be sent by • Click on button • Press “F” Key • Can be saved using the “my.settings”

  34. Settings Page • Speed & pitch Control • Slide Bar with Max and Min Set • Preset Send Keys • Captions and Values • Select “com” port for Key • “Enumerate” ports • Fills the drop down box • Other tweaks • Swap paddles • Enable/Disable “auto complete”

  35. Future Options • Two Tone Railway Morse • Needs an extra property on the morse object • Sending from File • Load file into text control • “Skins” • Change the color and font • “Classic”, “Modern”, “ArtDeco”

  36. Questions?

More Related