avatar
Fastest is list merging.
mlich.zam.slu.cz/js-sort/sorting2.htm
Try 7 fastest algorithm and array of 1.000.000 integers, Firefox browser; 0.3s javascript.
Warning: FF do code optimalization for repeating, you myabe must do refresh for more testing)

Example1 O(n) = n to n*log(n)
4352
sorted 4, 35, 2 (multi value list)
concat 345, 2
concat 2345
Example 1 you can modify for detect all sorted by ASC or DESC, as Timsort.

Example2 O(n) = n*log(n)
4352
sorted 4, 3, 5, 2 (single list)
concat 34, 25
concat 2345
avatar
avatar
That's great news!
Can't find where to e-mail your though.
Could you upload the files somewhere?
avatar
Alex has sent me files for laser cutting the parts, if you would like a copy drop me an email.
avatar
I think I have found Alex on Facebook and asked him if he still has the files :) hope its the right guy.
avatar
I had the same issue as you in the case of the pinout aswell Man Ceamara, with mine pins PD0 > PD3 where available so I used them instead.
The author mentions some code changes on his followup post here, also involving the direction.
He never posted the changes though: geektimes.ru/post/258650/

In my case I do have access to a laser cutting machine so I'd therefore like the 3D models.
I'm simply too lazy to figure out the dimensions by myself :D
As it is the motor works fine driven by my Arduino, but it does not make much useful work just sitting there oin my table turning :D
avatar
Its worth noting that I found you can change the direction of the motor by editing the line that reads
double speeds = 271.6; change that line to double speeds = -271.6; and you should be in a good place to start tracking in he other direction depending on your hemisphere.
avatar
Great to hear!
avatar
Hi, I have it running now. the problem was that the keypad shield I used was different to the one shown, I assumed that they would be interchangeable :(
I am using an LCD Shield supplied by Hobby Tronics, I have edited the code to use different connections so the motor interface has to be powered from the Analogue connectors A1,A2,A3,A4. I hope this helps someone and saves some heartache :)
— SKETCH--------------------------------------------------------------------------

/* This sketch drives an 28BYJ-48 stepper motor via its ULN2003 driver
* initial start speed is 271.6 to drive a screw for tracking stars during astro photography.
The value of adc-key-in has been altered to reflect the values delivered by the HobyTronics unit
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 195) return btnUP;
if (adc_key_in < 380) return btnDOWN;
if (adc_key_in < 555) return btnLEFT;
if (adc_key_in < 790) return btnSELECT;
*/

#include
#include
#define HALFSTEP 8
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int adc_key_val[5] ={50, 195, 380, 555, 790 };

/*Motor pin definitions when using HobbyTronics Keypad shield
have been changed to 15 16 17 18.
*/
#define motorPin1 15 // IN1 on the ULN2003 driver 1
#define motorPin2 16 // IN2 on the ULN2003 driver 1
#define motorPin3 17 // IN3 on the ULN2003 driver 1
#define motorPin4 18 // IN4 on the ULN2003 driver 1

/*
original code using the authors keypad, the pinouts have to
be changed when using the hobby tronics keypad, this is the original
outputs allocated
#define motorPin1 3 // IN1 on the ULN2003 driver 1
#define motorPin2 4 // IN2 on the ULN2003 driver 1
#define motorPin3 5 // IN3 on the ULN2003 driver 1
#define motorPin4 6 // IN4 on the ULN2003 driver 1
*/

int NUM_KEYS = 5;
int adc_key_in;
int key=-1;
int isRun;
double speeds = 271.6;
int maxspeed = 1245;

AccelStepper stepper1(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);

void setup() { // void means dont expect any return from this command
lcd.clear(); // clear the lcd
lcd.begin(16, 2); // set up the LCD's number of columns and rows:
lcd.setCursor(0,0);
lcd.print(" Stopped "); // display stopped on the LCD
lcd.setCursor(0,1);
lcd.print(«Speed „); // display the value of speed
lcd.print(speeds); // display the value of speeds
lcd.print(“ „);
isRun = 0;

stepper1.setMaxSpeed(maxspeed); //1245
stepper1.setSpeed(speeds); //271.6
}

void loop() {
adc_key_in = analogRead(0); // read the value from the sensor
key = get_key(adc_key_in); // convert into key press
if (key >= 0) // if keypress is detected
{
if (key == 1) {
speeds += 0.1;
delay(50);
}
if (key == 2 && speeds > 0) {
speeds -= 0.1;
delay(50);
}
if (key == 0) {
speeds += 10;
}
if (key == 3) {
speeds -= 10;
}
if (speeds>maxspeed) {
speeds = maxspeed;
}
if (speeds<-maxspeed) {
speeds = -maxspeed;
}
if (key == 4) {
isRun = 1 — isRun;
lcd.setCursor(0,0);
if (isRun == 1) {
lcd.print(“+++ Running +++ „);
} else {
lcd.print(“ Stopped „);
}
delay(250);
}
lcd.setCursor(0, 1);
lcd.print(“Speed „);
lcd.print(speeds);
lcd.print(“ „);
stepper1.setSpeed(speeds);
delay(50);
}
if (isRun == 1) {
stepper1.runSpeed();
}
}

int get_key(unsigned int input)
{
int k;
for (k = 0; k < NUM_KEYS; k++)
{
if (input < adc_key_val[k])
return k;
}
if (k >= NUM_KEYS)
k = -1; // No valid key pressed
return k;
}
avatar
Has anyone got this running, I finally completed the build but the motor does not run.
avatar
Hi Hanzzon, I don't have access to a 3d printer, instead I searched on line and found on ebay 2 gears that will work for me, they are made of brass so I will be able to drill the small one to suit the 5mm motor shaft and I will drill out the large gear and either solder or epoxy a nut to the gear being careful that it is dead centre. All of the wooden parts I have made and bent the rod, I'm just waiting for the motor, ball head, and LCD screen then I can assemble and test.
avatar
Indeed I noticed the same, on the last line some HTML has snuck in on this site…
Did you manage to find the source 3D files for the construction anywhere?
avatar
Original site here geektimes.ru/post/258646/
avatar
Trying to compile the above script failed, but using the script from the original site worked.
#include
#include

#define HALFSTEP 8
LiquidCrystal lcd(8, 13, 9, 4, 5, 6, 7);
int adc_key_val[5] ={50, 200, 400, 600, 800 };

// Motor pin definitions
#define motorPin1 3 // IN1 on the ULN2003 driver 1
#define motorPin2 4 // IN2 on the ULN2003 driver 1
#define motorPin3 5 // IN3 on the ULN2003 driver 1
#define motorPin4 6 // IN4 on the ULN2003 driver 1

int NUM_KEYS = 5;
int adc_key_in;
int key=-1;
int isRun;
double speeds = 271.6;
int maxspeed = 1245;

AccelStepper stepper1(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);

void setup() {
lcd.clear();
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.print(" Stopped ");
lcd.setCursor(0,1);
lcd.print(«Speed „);
lcd.print(speeds);
lcd.print(“ „);
isRun = 0;

stepper1.setMaxSpeed(maxspeed);
stepper1.setSpeed(speeds);
}

void loop() {
adc_key_in = analogRead(0); // read the value from the sensor
key = get_key(adc_key_in); // convert into key press
if (key >= 0) // if keypress is detected
{
if (key == 1) {
speeds += 0.1;
delay(50);
}
if (key == 2 && speeds > 0) {
speeds -= 0.1;
delay(50);
}
if (key == 0) {
speeds += 10;
}
if (key == 3) {
speeds -= 10;
}
if (speeds>maxspeed) {
speeds = maxspeed;
}
if (speeds<-maxspeed) {
speeds = -maxspeed;
}
if (key == 4) {
isRun = 1 — isRun;
lcd.setCursor(0,0);
if (isRun == 1) {
lcd.print(“+++ Running +++ „);
} else {
lcd.print(“ Stopped „);
}
delay(250);
}
lcd.setCursor(0, 1);
lcd.print(“Speed „);
lcd.print(speeds);
lcd.print(“ „);
stepper1.setSpeed(speeds);
delay(50);
}
if (isRun == 1) {
stepper1.runSpeed();
}
}

int get_key(unsigned int input)
{
int k;
for (k = 0; k < NUM_KEYS; k++)
{
if (input < adc_key_val[k])
return k;
}
if (k >= NUM_KEYS)
k = -1; // No valid key pressed
return k;
}
avatar
I want to build one can you help me?
avatar
avatar
To understand a J statement you can use ;: or the dissect add-on

1) ;: '(]%[**:@>:@])[:^[:-%~' NB. looks better in fixed width
┌─┬─┬─┬─┬─┬──┬─┬──┬─┬─┬─┬──┬─┬──┬─┬─┬─┐
│(│]│%│[│*│*:│@│>:│@│]│)│[:│^│[:│-│%│~│
└─┴─┴─┴─┴─┴──┴─┴──┴─┴─┴─┴──┴─┴──┴─┴─┴─┘
2) code.jsoftware.com/wiki/Vocabulary/Dissect
avatar
The matrix version is better than the iterative version because the latter is 0(n) and so O(2^z)
avatar
However in my opinion time complexity is O(z) since it's still linear, In fact ,we consider n as a integer so that its real input size is 2^z .Finally O(log(n)) can be written as O(z);
avatar
Were you already able to test your setup?