Pages: 1 [2] 3   Go Down
Author Topic: Quick suggestion on approaching this problem  (Read 2415 times)
0 Members and 1 Guest are viewing this topic.
United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Please explain what you mean by "pressing the key too fast" and "doesn't press the note". If you have added code to play tones, post the code as you now have it.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
  if (chqC<thres)
  {
    store=HIGH;
  }   

  else if (chqC>=thres)
If chgC is not less than thres, is there any possible way for it not to be greater than or equal to thres?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please explain what you mean by "pressing the key too fast" and "doesn't press the note". If you have added code to play tones, post the code as you now have it.

I know the code is working when I test it in the serial monitor. However when I go to test it with the virtual keyboard most times a note is not being played. When it does play the note it is very quick and easily missed.



Code:
  if (chqC<thres)
  {
    store=HIGH;
  }   

  else if (chqC>=thres)
If chgC is not less than thres, is there any possible way for it not to be greater than or equal to thres?

You are correct, any time chqC is not less than thres, it is automatically assumed that it will be greater than or equal to the thres. I have that line so that the store value can get overwritten.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I have that line so that the store value can get overwritten.
You need the else statement so that the store value can get overwritten, not the else if statement.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You need the else statement so that the store value can get overwritten, not the else if statement.

Code:
else  {
       store=LOW;
         }


Something like that? Just tried running the code again and I'm having any luck.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Just tried running the code again and I'm having any luck.
Luck has nothing do with writing code that works. Debugging does. I don't see any Serial.print() statements in your code that tell you what is happening.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I left them out because I was scared that they would interfere with the AAC keys readings.
I wrote a separate code to test the laser and make sure it is working and I was using the right values.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Please explain what you mean by "pressing the key too fast" and "doesn't press the note". If you have added code to play tones, post the code as you now have it.

I know the code is working when I test it in the serial monitor. However when I go to test it with the virtual keyboard most times a note is not being played. When it does play the note it is very quick and easily missed.

What exactly is the "virtual keyboard", and how have you connected it?
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please explain what you mean by "pressing the key too fast" and "doesn't press the note". If you have added code to play tones, post the code as you now have it.

I know the code is working when I test it in the serial monitor. However when I go to test it with the virtual keyboard most times a note is not being played. When it does play the note it is very quick and easily missed.

What exactly is the "virtual keyboard", and how have you connected it?

http://www.youtube.com/watch?v=Svkh31xh5VI&feature=youtu.be I recorded a quick video to demonstrate the behaviour. Note that I decided to use an L.E.D. now because I thought it may have been some power issues with the actual laser but it appears it doesn't make a difference they are both behaving in the same way.

I am using a program called Mixcraft. I turned on the virtual keyboad in the program which allows me to use my computer keyboard. I don't think it's the virtual keyboard software's problem. I know this only because I also tried opening a word document and noticed that most times "a" doesn't appear, or it appears very delayed and some are dead on.
« Last Edit: January 01, 2013, 03:34:17 pm by FullyJosh » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Anyone else have an idea on why the code would work in the serial monitor but not with aac keys enabled?
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What data does Mixcraft expect? How is it supposed to know how long a note is?
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What data does Mixcraft expect? How is it supposed to know how long a note is?

Mixcraft will turn my computer keyboard into an actual musical keyboard. When I press the "a" key it plays the note and it will hold the note until I release my finger.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That's the problem then. There is no way that a serial port sending ASCII codes can convey information about how long a key was pressed. I think a Leonardo could do it, because I believe it can emulate a USB PC keyboard, for which the up- and down-codes are sent separately.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's the problem then. There is no way that a serial port sending ASCII codes can convey information about how long a key was pressed. I think a Leonardo could do it, because I believe it can emulate a USB PC keyboard, for which the up- and down-codes are sent separately.

Problem with that is that the Leonardo doesn't have enough analog pins.

Do you know how I can fix the issue where your code works flawlessly in the serial monitor but starts glitching when I turn on aac keys?
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That's the problem then. There is no way that a serial port sending ASCII codes can convey information about how long a key was pressed. I think a Leonardo could do it, because I believe it can emulate a USB PC keyboard, for which the up- and down-codes are sent separately.

Problem with that is that the Leonardo doesn't have enough analog pins.

Do you know how I can fix the issue where your code works flawlessly in the serial monitor but starts glitching when I turn on aac keys?

Not without using a Leonardo or other device that can emulate a keyboard that returns scan codes. How many analog inputs do you need, and why? The Leonardo has 12, and you can add more using an external ADC or analog multiplexer.
« Last Edit: January 04, 2013, 06:07:51 pm by dc42 » Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Pages: 1 [2] 3   Go Up
Jump to: