Bi directional Teensy

Status
Not open for further replies.
It's possible to send and receive data over USB with a Teensy 2.0 (and all the other models).

Can you say more about what you mean by "vending data"? If you tell us what problem you're trying to solve in more detail (overall goal, requirements, constraints, etc.), you've got a better chance of getting a good answer.
 
We manufacture novelty vending machines. We have 2 models. 1 that dispenses 1 toy and the 2nd machine that dispenses 3 different toys. We are looking to gather data and have it transmitted via USB directly from the teensy 2.0.
The data I am trying to pull would be, on the larger machine- "which particular product was dispensed." there are 3 buttons to make 3 different selections. all 3 selections have a cherry switch attached so that when a product dispenses it triggers the switch, which than sends a signal to the motor to stop spinning. We are developing a database where all the data from each machine will be stored and accessible by our customers via an online portal.
 
Thus, it's simply about connecting the "product went through" signal to pins of the Teensy, attach an interrupt to each of these pins and sending a message via USB. Easy-peasy, as long as the Teensy is connected to a device with an USB host.
 
Here is a scope of my project for a better understanding of what I am trying to accomplish.
 

Attachments

  • Teensy Scope.doc
    51 KB · Views: 85
From the file:

Task: Collect vended data by transmitting the vended data through Teensy 2.0 Micro controller via USB. Micro USB will be connected directly to Android Box.

Deliverable: The goal of this project is to develop all the components needed for data to be transmitted from the Teensy 2.0, and stored to be accessible by customers via online portal. Data to be transmitted would be, Various states of the machine, differentiate which product was dispensed by which selection button was either pushed or by which cherry switch was closed by vended product.

Hardware:

Teensy 2.0 (USA) – Hardware that will be used to send vended data
MXQ PRO 4K - (Android device to control core functions of attached devices)
Micro USB – Cable Harness that provides a physical connection between the Teensy 2.0 and MXQ PRO 4K.
 
First, please let me state the obvious. This project involves programming 2 or more devices which will communicate with each other. I can only comment on the Teensy side. You're going to need to talk with whoever will program the MXQ PRO 4K Android Box. Ultimately, some method to send data from Teensy to that device needs to be used.

Teensy supports many ways to send data over USB. Hopefully at least one of them will be able to work with that MXQ PRO 4K.

The most commonly used communication with desktop & laptop PCs is USB Serial. On Teensy, you simply use Serial.print() to send data. When using Arduino, all you need to do is select the Teensy's serial port (after it's running your program) from the Tools > Ports menu, then click the serial monitor button (far right side of the toolbar, or use the Tools menu). Arduino's serial monitor window will appear and you should see the data in that window.

Now I said I can't comment on the Android side, but in general hypothetical terms, you would write some program or app on the Android box which listens for that serial port and does whatever you want with the data incoming from Teensy.

Regular computers running Linux, Mac OS or Windows 10 have excellent support for USB serial, and older versions of Windows can do it after you install a driver. Whether Android, I do not know. In fact, I've never really used an Android device. I know almost nothing about Android.

I can tell you Teensy has many ways it can send data. Another option might be to have Teensy act as a USB keyboard. This is done by selecting one of the options in Tools > USB Type with Keyboard. Then in your program, you use Keyboard.print() instead of Serial.print(). To your PC or the Android box, Teensy is seen as a keyboard and the data arrives as if a person were typing very quickly. So if Android can't do USB serial, or if getting it to use serial is too much trouble, having Teensy be a USB keyboard and just send the data as keystrokes is probably one of your options. Just like a real keyboard, the trick will probably involve making sure the right program on your Android box actually receives the incoming keystrokes. That's a detail you'll need to sort out on the Android side, and remember, I know pretty much nothing about how Android works.

I can point you to the examples in Arduino. Click File > Examples > Teensy > USB_Keyboard > Buttons to get started. That particular example will send keyboard messages when buttons connected to the first several pins are pressed. If you just program it onto a Teensy which isn't connected to anything else, it's easy to experiment by carefully touching a wire or paperclip between GND and the nearby pins. Assuming the cursor is in a window that can receive keystrokes (like Notepad or Arduino's editor), you'll see words appear on your screen as if you had typed them.

Hopefully this can help you get started. Even though your ultimate goal is interfacing with Android, I would highly recommend you invest a little time just playing with the Teensy board using that example program and watching the keystrokes appear. Then when you deal with the Android, or talk with other people who will do the Android development, you'll have practical experience with how the Teensy side works. Especially if you pay a consultant an hourly rate for the Android stuff, having the Teensy side worked out will very likely save you quite a lot of time & money.
 
Status
Not open for further replies.
Back
Top