Source language: Translate to:

Read contact closure from NB

Using NeoBook to control external hardware and devices.

Moderator: Neosoft Support

Re: Read contact closure from NB

Postby DaveJ » Sun Aug 10, 2014 6:50 am

Hi Don,
You would use the Arduino to interface between the button and the PC.
Image

The code is quite simple;

Code: Select all
// this constant won't change:
const int  buttonPin = 2;    // the pin that the pushbutton is attached to

// Variables will change:
int buttonState = 0;         // current state of the button
int lastButtonState = 0;     // previous state of the button

void setup() {
  // initialize the button pin as a input:
  pinMode(buttonPin, INPUT);

  // initialize serial communication:
  Serial.begin(9600);
}


void loop() {
  // read the pushbutton input pin:
  buttonState = digitalRead(buttonPin);

  // compare the buttonState to its previous state
  if (buttonState != lastButtonState) {

    if (buttonState == HIGH) {
      // if the current state is HIGH then the button
      // went from off to on:
      Serial.println("on");
    }
    else {
      // if the current state is LOW then the button
      // went from on to off:
      Serial.println("off");
    }
  }
  // save the current state as the last state,
  //for next time through the loop
  lastButtonState = buttonState;
 
}


At 9600 baud, the circuit will send a message of 'on' or 'off' when the button is pushed or released.
You just need to ask Neobook to read the serial port.

I would probably use the Arduino Nano as you can get them for less than $4 with a mini USB for power and data. Remember that theses devices are running at 16MHz so you should see no delay.

Dave J
DaveJ
 
Posts: 90
Joined: Tue Dec 30, 2008 11:06 am

Re: Read contact closure from NB

Postby ebear » Sun Aug 10, 2014 7:50 am

Hello Don,

This can be done with a very simple electronic circuit and the existing plugin "gtRS232free7.nbp"
I use this already for two years for a ESD testing unit. For testing I have a simple button "on/off"

If interested I can sent you documentation how to do this.

Best regards,

Eric
http://www.lunarsoftware.eu - Lunar Software ERP database Development. Manufacturing processes, Document management, QMS, Stock management. Standalone solutions or connected to Helios Orange and other ERP systems.
User avatar
ebear
 
Posts: 270
Joined: Wed Jan 18, 2012 3:12 am
Location: Vrchlabi - Czech republic

Re: Read contact closure from NB

Postby ebear » Sun Aug 10, 2014 7:58 am

Hello Dave,

I'm using the gtRS232free7.nbp plugin for these kind of things, but... there are some problems with it:

First, as I know, it isn't supported anymore....
Second it is only usable for usb with a RS-232 to USB converter

I'm doing a lot of stuff with arduino, Velleman and also custom made hardware, so it would be great to have a solid plugin for RS-232 and USB communication, and I would be fine to pay a 50.- USD for it.

Yet another idea, could we have on this forum a sub forum something like "Neobook and Hardware control" ????

Regards,

Eric
http://www.lunarsoftware.eu - Lunar Software ERP database Development. Manufacturing processes, Document management, QMS, Stock management. Standalone solutions or connected to Helios Orange and other ERP systems.
User avatar
ebear
 
Posts: 270
Joined: Wed Jan 18, 2012 3:12 am
Location: Vrchlabi - Czech republic

Re: Read contact closure from NB

Postby datadon » Sun Aug 10, 2014 8:06 am

Ebear

Excellent idea. I concur. A new forum.

I would like you to send me anything you have on that plugin. You can send through this forum member contact.

Thanks
Don
Don

'If you want to get a brontosaurus from 'a' to 'b' then you ride the dinosaur - you don't carry it!'
User avatar
datadon
 
Posts: 389
Joined: Sun Apr 03, 2005 7:55 pm
Location: Lorena Texas

Re: Read contact closure from NB

Postby ebear » Sun Aug 10, 2014 1:14 pm

Hello Don,

I will publish it on the forum tomorrow, need to draw the schematics (It' very simple). Maybe someone else can also take use of it. If you need only a on/off solution then I think my design is the most simple solution.
Agree with the Arduino solution its very flexible for a lot of things, but to use it only for a on/off solution it's to much...

Let hope that Dave really jumps in the RS232 / USB plugin, this would really open a new world :), and also the "Neobook Hardware.... whatever" forum would be great.

Best regards,

Eric
http://www.lunarsoftware.eu - Lunar Software ERP database Development. Manufacturing processes, Document management, QMS, Stock management. Standalone solutions or connected to Helios Orange and other ERP systems.
User avatar
ebear
 
Posts: 270
Joined: Wed Jan 18, 2012 3:12 am
Location: Vrchlabi - Czech republic

Re: Read contact closure from NB

Postby ebear » Mon Aug 11, 2014 2:30 pm

Hello Don and all,

As promised I post the documentation for the "Simple ON/OFF RS-232" solution. The solution is usable for a RS-232 port, or via a RS-232 to USB cable via a USB port.
The plugin gtRS232free7.nbp is needed to use this sample.

A simple box is used with a few components:

Image
Image


Schematics:
Image

RS-232 Connect pin-out (see also schematics):
Image

Below my code. I use a loop because of my application but I think the code is simple and can be changed for your own needs...
Code: Select all
NBW Publication Source File
(C)2014 NeoSoft Corp.
Title=Untitled NeoBook Publication
Language=US
NeoBookVer=5,80
ScreenColors=16777216
ScreenWidth=800
ScreenHeight=600
BkndColor=0
ScreenAutoSize=Yes
LinkColor=16711680
WindowStyle=0
WindowOrder=0
WindowPos=0
WindowProps=31
BiDiMode=0
UseUpdateTimer=Yes
ReturnTime=60
ShapeTransColor=536870912
SplashProps=3
CompiledName=G:\000 Application Development\FisRS232\FisRS232.exe
CompileType=0
MediaType=0
FilesIncluded=1
FontsIncluded=2
FontsToCompile=|
CopyExternalFiles=No
SetupMedia=3
SetupInstDir=C:\MyProgram
SetupTitle=Setup
SetupColors=16711680|0|65535
Variables=[cport]¶[Loop]¶[Message]¶[rx]¶
VersionMajor=1
VersionMinor=0
VersionRelease=0
VersionBuild=0
ReqExLevel=1
CustomFontName=Arial
CustomFontSize=9
CustomFontStyle=0
CustomCharset=1
CacheSize=30
ExtractOp=132
L_OK=OK
L_CANCEL=Cancel
L_YES=Yes
L_NO=No
L_CLOSE=Close
L_ERRORTITLE=Error
L_FINDTITLE=Find
L_FINDPROMPT=Find &What
L_FINDFIRST=&Find First
L_FINDNEXT=Find &Next
L_FINDERROR=Search text not found.
L_PWORDTITLE=Password required
L_PWORDMSG=Before continuing, you must first|enter the correct password.
L_PWORDPROMPT=&Password:
L_PWORDERROR=That's not the right password!
L_MEDIAERROR=In order to play this type of file you must install|the appropriate multimedia hardware and/or|software.
L_INTERNETERROR=Unable to locate Internet Browser software.
L_ABORTFUNCTION=Do you want to cancel this function?
L_EXTRACTERROR=This file could not be extracted and cannot be played.
L_INSTDIRPROMPT=Please enter the drive and directory where you would like this program to be installed. To accept the default drive and directory, simply press Enter.
L_INSTFOLDERPROMPT=Do you wish to create a program folder?
L_INSTRUNPROMPT=Do you want to run
L_INSTDISKPROMPT=Please insert disk #
L_INSTDISKERROR=That's not the correct disk, try again.
L_INSTGENERROR=The installation has terminated.
L_INSTEXITPROMPT=Do you really want to cancel the installation?
L_INSTWINTITLE=Setup
L_INSTPROGTITLE=Extracting Files...
L_SENDEMAIL=Sending Mail...
L_MAILSERVER=Please enter the name of your outgoing email server:
L_COPY=Copy to Clipboard
L_SELECTALL=Select All
L_DONWLOADFILE=Downloading: %s
L_PLEASEWAIT=Please wait...
TrayMenuBegin
MenuName=TrayOpen
MenuText=Open
MenuState=3
MenuKey=0
MenuAction=SetVar "[WindowState]" "Normal"
MenuName=TrayExit
MenuText=Exit
MenuState=3
MenuKey=0
MenuAction=Exit "" ""
MenuEnd
MasterPage
NewPage=New Page
PageStyle=0
PageColor=16777215
PageGradient1=16711680
PageGradient2=255
PageGradientDir=1
WallpaperStyle=0
ObjectType=8
Name=Text1
X=0
Y=45
W=800
H=515
Anchor=5
Font=Arial
FontSize=150
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\qc\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs300\cf0 [rx]}}}
HMargin=0
VMargin=150
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
TabOrder=1
ObjectType=21
Name=Container1
X=0
Y=0
W=800
H=45
Anchor=1
LineColor=0
LineWidth=1
LineStyle=0
FillColor=10053171
FillPattern=0
TabOrder=3
HMargin=0
VMargin=0
ContainerBegin
ObjectType=3
Name=PushButton1
X=1
Y=1
W=100
H=43
Anchor=3
Text=Start
Align=2
ImageStyle=0
ObjAction=SetVar "[cport]" "4"¶SetVar "[rx]" "0"¶SetVar "[Message]" "Waiting...."¶SetVar "[ExitLoopRequested]" "False"¶Loop "1" "1000" "[Loop]"¶     gtCommOpenStd "4,1200"¶     gtCommRxCount "[cport],rx"¶     gtCommRxS "[cport],RXS,1"¶     gtCommRxByte "[cport],RXS,1"¶     If "[rx]" ">" "0"¶        SetVar "[Message]" "Done...."¶        AlertBox "Pressed" "The button is pressed, Test OK"¶        gtCommClose "[cport]"¶        ExitLoop¶     EndIf¶        If "[ExitLoopRequested]" "=" "True"¶      ExitLoop¶   EndIf¶EndLoop¶SetVar "[Message]" "Press startkey to test"¶SetVar "[rx]" "0"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=0
ObjectType=8
Name=Text2
X=101
Y=1
W=598
H=43
Anchor=5
Font=Arial
FontSize=24
FontStyle=0
FontCharset=1
TextColor=16777215
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\qc\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs48\cf0 [Message]}}¶}
HMargin=0
VMargin=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=1
TabOrder=1
ObjectType=3
Name=PushButton3
X=699
Y=1
W=100
H=43
Anchor=4
Text=Cancel
Align=2
ImageStyle=0
ObjAction=SetVar "[ExitLoopRequested]" "True"¶SetVar "[Message]" "Press startkey to test"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=2
ContainerEnd
ObjectType=21
Name=Container2
X=0
Y=560
W=800
H=40
Anchor=2
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
TabOrder=2
HMargin=0
VMargin=0
ContainerBegin
ObjectType=8
Name=Text3
X=25
Y=10
W=155
H=25
Anchor=0
Font=Arial
FontSize=150
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs24\cf0 [RXS]}}}
HMargin=0
VMargin=150
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
TabOrder=0
ContainerEnd


Button press in action:

Image

I hope the instructions are understandable, otherwise let me know....

Regards,

Eric
Last edited by ebear on Mon Aug 11, 2014 2:38 pm, edited 1 time in total.
http://www.lunarsoftware.eu - Lunar Software ERP database Development. Manufacturing processes, Document management, QMS, Stock management. Standalone solutions or connected to Helios Orange and other ERP systems.
User avatar
ebear
 
Posts: 270
Joined: Wed Jan 18, 2012 3:12 am
Location: Vrchlabi - Czech republic

Re: Read contact closure from NB

Postby datadon » Mon Aug 11, 2014 2:36 pm

Very cool! So if i hooked it up to a wifi relay (with contact closure from wifi signal) instead of the switch I should be able to get the same result.

I presume I could do the same thing with 8 different inputs from 8 relays? what would be needed to do that?
Don

'If you want to get a brontosaurus from 'a' to 'b' then you ride the dinosaur - you don't carry it!'
User avatar
datadon
 
Posts: 389
Joined: Sun Apr 03, 2005 7:55 pm
Location: Lorena Texas

Re: Read contact closure from NB

Postby ebear » Mon Aug 11, 2014 2:42 pm

Hi Don,

This is a very simple solution for an ON/OFF. But please give me some more information what you exactly wants to do. If I read 8 relays etc, then I think you would really need something like Arduino.
But please tell more about your idea....

Regards,

Eric
http://www.lunarsoftware.eu - Lunar Software ERP database Development. Manufacturing processes, Document management, QMS, Stock management. Standalone solutions or connected to Helios Orange and other ERP systems.
User avatar
ebear
 
Posts: 270
Joined: Wed Jan 18, 2012 3:12 am
Location: Vrchlabi - Czech republic

Re: Read contact closure from NB

Postby datadon » Mon Aug 11, 2014 2:52 pm

I have different needs, probably like others. For one application the single input is good. But for others like gaming using a smartphone as input I would need to know which phone is sending the signal so a wifi relay does that, but to my knowledge you can only control one relay per phone. So for 8 phones i need 8 relays or inputs. The arduino is certainly a possibility also. I'm just learning how to make all these toys work together. I'm also working this from the script side as well. Just looking for best way to do it.

This probably all sounds pretty convoluted to those who know how to do these things so I just plug along and see if something clicks (lttle play on words there, plug clicks :-)
Don

'If you want to get a brontosaurus from 'a' to 'b' then you ride the dinosaur - you don't carry it!'
User avatar
datadon
 
Posts: 389
Joined: Sun Apr 03, 2005 7:55 pm
Location: Lorena Texas

Re: Read contact closure from NB

Postby ebear » Mon Aug 11, 2014 2:58 pm

Don,

Each phone has his own IP address on the WiFi router, isn't it possible to use the IP address to find out which phone is sending??? Only an idea....

Eric
http://www.lunarsoftware.eu - Lunar Software ERP database Development. Manufacturing processes, Document management, QMS, Stock management. Standalone solutions or connected to Helios Orange and other ERP systems.
User avatar
ebear
 
Posts: 270
Joined: Wed Jan 18, 2012 3:12 am
Location: Vrchlabi - Czech republic

Re: Read contact closure from NB

Postby datadon » Mon Aug 11, 2014 4:57 pm

You are absolutely right. That is how I do it when using the NB browser and writing to a mysql table. It records the imei number.

But with a wifi relay, it is just a contact so even though it knows that info there is not much for it to do with it but close the contact. In the eight relay board It gives me some possibility as each phone, using some form of id turns on a different relay and closes a different contact. Does that make any sense. What I really would like is a device that can externally to NB, read the phone id and then send an input to NB that identifies it as to which phone it is. Not being a php'er, I must rely on others for scripts to do this. If I had a device that would that and plugin into the pc and send a signal to NB I could do just fine with it inside NB.
Don

'If you want to get a brontosaurus from 'a' to 'b' then you ride the dinosaur - you don't carry it!'
User avatar
datadon
 
Posts: 389
Joined: Sun Apr 03, 2005 7:55 pm
Location: Lorena Texas

Re: Read contact closure from NB

Postby datadon » Tue Aug 12, 2014 3:50 am

Ebear

I didn't thank you all that great work you did in posting your project and pub. Thank you for that. It will be very useful.

Can you tell me where to get the plugin you referenced

gtRS232free7.nbp

Thanks
Don
Don

'If you want to get a brontosaurus from 'a' to 'b' then you ride the dinosaur - you don't carry it!'
User avatar
datadon
 
Posts: 389
Joined: Sun Apr 03, 2005 7:55 pm
Location: Lorena Texas

Re: Read contact closure from NB

Postby ebear » Tue Aug 12, 2014 7:48 am

Hello Don,

Here it is:

Http://www.fseg.eu/neobook/gtCommsv7.01.rar

Regards,

Eric
http://www.lunarsoftware.eu - Lunar Software ERP database Development. Manufacturing processes, Document management, QMS, Stock management. Standalone solutions or connected to Helios Orange and other ERP systems.
User avatar
ebear
 
Posts: 270
Joined: Wed Jan 18, 2012 3:12 am
Location: Vrchlabi - Czech republic

Re: Read contact closure from NB

Postby dpayer » Tue Aug 12, 2014 9:06 am

Very cool stuff!

I've been reading more about arduino and RasperryPi recently and it is all so interesting but it is an area I do not have a lot of experience in. A forum here would be a good thing.

I suggest you write Dave @ Neosoft directly and request a new forum entry. He may not be reading this thread. I know he is open to any way NB could be promoted.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1383
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: Read contact closure from NB

Postby frednet » Tue Sep 23, 2014 3:53 pm

datadon wrote:Still waiting for that elusive plugin that will make it simple to read a contact closure in Neobook. Take a USB cable, select a pair of wires, run them to both sides of the normally open contact. When it closes the plugin records it and who knows what we can do with it then. Don't need any analog data, just on or off.

Lots of possible applications.

Any takers?

Thanks


Don,
Take a look at this thread
http://www.neosoftware.com/community/viewtopic.php?f=3&t=16774
I use this velleman board and the plugin mentioned to read contact closure. I use the thing to control an old analog sattelite dish.
the board velleman vm110 is readybuild and connects through usb.

Another option would be to use the one wire protocol. I managed to make a one wire interface to rs232 and to my big surprise it also works with a simple usb to serial converter which is very nice because most computers no longer have serial ports.
http://en.wikipedia.org/wiki/1-Wire
some examples that stils require some coding
http://www.hobby-boards.com/store/products.php?product=Dual-Counter

The most simple thing would be to use a gameport
http://www.neatinformation.com/technology/joystick.html
but finding the software to read it could be cumbersome.
User avatar
frednet
 
Posts: 83
Joined: Fri Sep 23, 2005 4:29 am
Location: netherlands

PreviousNext

Return to Neobook and Hardware Control

Who is online

Users browsing this forum: No registered users and 1 guest