Pulse Width Modulation using visual basic

Discussion in 'Programmer's Corner' started by Spogpean, Feb 20, 2008.

  1. Spogpean

    Thread Starter New Member

    Feb 5, 2008
    8
    0
    hi all,

    im trying to impliment PWM control of a heating element using visual basic, but have come unstuck. i cannot find ANYTHING on the net about it. would anyone have any kind of source code that i could use?

    regards
     
  2. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    You may have a hard time with VB. It does not have those nice old PEEK and POKE functions that allow low-level hardware access. It will take a different language like Power Basic or X Basic, or else in-line assembler to let you do PWM.

    What port or interface were you going to use?
     
  3. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    I wouldn't try to do PWM straight from Visual Basic. Timing would vary widely depending upon events outside of program control.

    But you could use it to communicate with a microcontroller that's actually performing the PWM.
     
  4. Spogpean

    Thread Starter New Member

    Feb 5, 2008
    8
    0
    Thanks for the replys sos far lads. So could I build a PWM Circuit, and then use the VB to see the signals generated on a graph or something?

    I need to see the PWM signal on the screen, how would I go about doin that?

    Thanks!
     
  5. Spogpean

    Thread Starter New Member

    Feb 5, 2008
    8
    0
    anyone got any info??
     
  6. thingmaker3

    Retired Moderator

    May 16, 2005
    5,072
    6
    If your frequency is low enough, you can buy or build one of the PC oscilloscopes. If your frequency is to high for that, you might have to get creative with your serial port and software other than VB.
     
  7. Ian_McCrum

    New Member

    Mar 9, 2008
    1
    0
    You could get VB to generate PWM - since you are driving a heating element then the TIMER activeX control could output a waveform that is high and low, say over 1/10th of a second. You set the interval of the timer to the number of milliseconds you want - it is probably only accurate to a millisecond (I think there is a way of getting more accuracy).

    Certainly when I use the timer in animation I do not notice any "Jerkiness"

    Presumably for your project you need to sense temperature and output an on-off signal. The input and output will be harder than getting PWM. Sounds like you could use the parallel port for that... any more details?

    Ian McCrum
    IJ.McCrum@ulster.ac.uk

    __
     
Loading...