[QUOTE=Leestons;42977804]That makes sense, thank you![/QUOTE]
[url=http://www.falstad.com/circuit/#%24+1+5.0E-6+10.20027730826997+50+5.0+50%0Av+128+288+128+368+0+1+40.0+339.0+0.0+0.0+0.5%0Av+128+144+128+224+0+1+40.0+339.0+0.0+0.0+0.5%0Ar+240+80+320+80+0+200.0%0Ag+320+80+320+96+0%0Ag+128+368+128+384+0%0Ar+128+144+128+80+0+1.0%0Aw+160+80+128+80+0%0Av+272+288+272+368+0+1+40.0+339.0+0.0+0.0+0.5%0Av+352+288+352+368+0+1+40.0+339.0+0.0+0.0+0.5%0Ar+352+288+352+224+0+1.0%0Ar+272+288+272+224+0+1.0%0Ag+272+368+272+384+0%0Ag+352+368+352+384+0%0Aw+272+224+352+224+0%0Aw+352+224+352+176+0%0Ar+352+176+416+176+0+100.0%0Ag+416+176+416+192+0%0Ar+128+288+128+224+0+1.0%0As+160+80+240+80+0+0+false%0As+160+32+240+32+0+1+false%0Aw+160+32+160+80+0%0Ar+320+32+240+32+0+400.0%0Ag+320+32+320+48+0%0Ax+346+96+535+100+0+18+Same+current%2C+4x+power%0Ax+348+41+548+45+0+18+Same+power%2C+half+current%0Ao+5+64+1+35+40.0+9.765625E-5+0+-1%0Ao+2+64+0+33+640.0+6.4+0+-1%0Ao+9+64+1+35+5.0+9.765625E-5+1+-1%0Ao+15+64+0+33+320.0+6.4+1+-1%0A]Here's a visual example you can play around with.[/url]
[QUOTE=LoneWolf_Recon;42977611]...[/QUOTE]
Have you considered replacing the Uno regulator with a low power regulator ?
Wow, what a great deal! Only 2 dollars for a 4700µF 10V capacitor!
[url]http://www.adafruit.com/products/1589[/url]
:v:
[QUOTE=Chryseus;42977898]Have you considered replacing the Uno regulator with a low power regulator ?[/QUOTE]
You can even get a tiny switchmode power supply that can be used to replace/bypass the arduino's onboard linear regulators ([url]http://uk.farnell.com/on-semiconductor/ncp1117st50t3g/ldo-reg-20vin-1a-5v-1-sot223-3/dp/2112617[/url] and [url]http://uk.farnell.com/texas-instruments/lp2985-33dbvr/ic-ldo-volt-reg-3-3v-150ma-5-sot/dp/2126531[/url]).
They're much more efficient than good ol' analog linear regulators .
Some of those switchmode regulators even have a shutdown pin that might be handy for your application.
[QUOTE=Chryseus;42977898]
Have you considered replacing the Uno regulator with a low power regulator ?[/QUOTE]
I have, however this is a class project thus was curious if there is another way before I go out and get a switch mode (There is a $40 Project Budget)
[QUOTE=LoneWolf_Recon;42979281]I have, however this is a class project thus was curious if there is another way before I go out and get a switch mode (There is a $40 Project Budget)[/QUOTE]
Nvm, I solved it, I used a separate ATtiny85 to monitor battery levels and switch off the Uno's power when charging.
Finally finished my latest project. :dance:
Actually my first decent PCB.
If you want the gerber files PM me.
[thumb]http://u.cubeupload.com/Chryseus/8G1AsN.png[/thumb]
[thumb]http://u.cubeupload.com/Chryseus/tyovtB.png[/thumb]
[QUOTE=Chryseus;43008430]
[thumb]http://u.cubeupload.com/Chryseus/tyovtB.png[/thumb][/QUOTE]
Someone to care for, to be there for. I have James Woods!
[img]http://i00.i.aliimg.com/photo/v0/100165864/Jumper_Wire_Resistor.jpg[/img]
Gee, that seems kind of.....redundant?
[QUOTE=pentium;43015440][img]http://i00.i.aliimg.com/photo/v0/100165864/Jumper_Wire_Resistor.jpg[/img]
Gee, that seems kind of.....redundant?[/QUOTE]
0-ohm resistors, used for bridges on 1-sided PCBs.
Those look handy.
oh man i always wondered where do manufacturers get loads of resistor leads. i used to order the cheapest resistors and just snip their leads when i needed those.
Just "finished" a project for my digital logic (in Verilog) course...
State of the project when I demo'd it.
[t]https://dl.dropboxusercontent.com/u/64514745/ECE241Project.png[/t]
Will post a video of it later.
FYI, it's all done on "hardware", Altera DE2 FPGA.
Had about 2.5 - 3.5k lines of verilog, although it complied into only about 1,500 logic elements. (some guys working on a factual generating design had about 1k lines of code, but used close to 30k logic elements, which was the max of the DE2)
You know you can buy solid wire right guys ?
[QUOTE=Chryseus;43026363]You know you can buy solid wire right guys ?[/QUOTE]
Shh, they're already baffled by pre-cut lengths of pre-tinned copper wire.
Telling them you can buy Meters of it for even cheaper would just literally blow their minds.
So my dads job is to do programming for cameras and shit and he knows I like to tinker with electronics, so he was like "here I got this left over." and handed me an ATMEL TH7815ACC 50MHz linear CCD.
So yeah.
I have no clue what to do with it...
It came in a neat little box:
[t]http://w84.img-up.net/CAM00142c708.jpg[/t]
[t]http://i35.img-up.net/CAM00143257a.jpg[/t]
[editline]30th November 2013[/editline]
Wow what that thing needs 15V DC input.
Yeah fuck that.
[QUOTE=nutcake;43027789]
Wow what that thing needs 15V DC input.
Yeah fuck that.[/QUOTE]
15V isn't high or unusual for a CCD.
But I only have a Raspi. :c
[QUOTE=nutcake;43028287]But I only have a Raspi. :c[/QUOTE]
Time to go shopping then, buy a nice variable power supply or build your own.
Are there situations where a voltage doubler / quadrupler / etc circuit is worth it, as opposed to just getting a higher voltage source of electricity?
[QUOTE=Nikita;43029825]Are there situations where a voltage doubler / quadrupler / etc circuit is worth it, as opposed to just getting a higher voltage source of electricity?[/QUOTE]
If you need higher voltage but low current then voltage multipliers do a pretty good job, voltage doublers works pretty well but anything more and you need to avoid loading it.
[QUOTE=Chryseus;43030150]If you need higher voltage but low current then voltage multipliers do a pretty good job, voltage doublers works pretty well but anything more and you need to avoid loading it.[/QUOTE]
Pretty much. A charge pump (like the voltage doubler) can come in quite handy when you need low currents. One of the most common applications that comes to mind is to generate the negative contrast voltage on LCDs.
[QUOTE=DrDevil;43015520]0-ohm resistors, used for bridges on 1-sided PCBs.[/QUOTE]
I'm sure there's a good amount of resistance in that wire. Maybe.... 1.0e10-999999....uOhms
Tried adding a piezoelectric speaker to my geiger counter.
[IMG]http://i11.photobucket.com/albums/a166/ballsandy/IMG_3960.jpg[/IMG]
...but it really feels like it needs an amp.
[t]https://dl.dropboxusercontent.com/u/64514745/tetrisphotos/2013-11-28%2010.36.02.jpg[/t]
[code]module MainFSM
(
keyboard,
reset,
clock,
reduced_clock,
memory_read_data,
memory_address,
memory_write_data,
memory_write_enable,
state_output, //Main FSM state_output
new_block, //new block generation
block_shape, //current updating block
block_location_x,
block_location_y,
block_color,
next_block_shape, // next block selector
next_block_color,
score,
statedebug,
memory_counter_x,
memory_counter_y,
GRID_SIZE_X,
GRID_SIZE_Y,
hit,
column_exists,
debugout1,
debugout2
);
output [3:0]debugout1;
wire [3:0]debugout1;
assign debugout1 = memory_counter_y * BLOCKSIZE + memory_counter_x;
output [3:0]debugout2;
//wire [3:0]debugout2;
assign debugout2 = left_right+1;
parameter BLOCKSIZE = 3'd4, // 4x4 block sizes
GRID_CENTER_LOCATION_X = 4'd6, //offset by 1 +2, since moving corner up-left when loading. 2 is due to overflow reasons
GRID_CENTER_LOCATION_Y = 5'd0,
SCORE_LOCATION_X = 9'd35,
SCORE_LOCATION_Y = 8'd160,
BLANK_COLOR = 3'b000,
// MOVEDELAY = 32'h4C4B40, //live :h4C4B40 // medium: d10 //slow: d2
MOVEDELAY = 32'd7,
SHIFTDELAY = 32'd2;
// SHIFTDELAY = 32'h1312D0;
// SHIFTDELAY = 32'h4C4B40;
//wire MOVEDELAY;
//assign MOVEDELAY = down ? 'd2 : 'd8;
// wire MOVEDELAY;
// assign MOVEDELAY = keyboard[1] ? 32'd2: 32'h4C4B40 ;
input [3:0]GRID_SIZE_X;
input [4:0]GRID_SIZE_Y;
input [7:0]keyboard; //
wire up, left, right, down, enter, esc, pause;
assign up = keyboard[0];
assign left = keyboard[1];
assign down = keyboard[2];
assign right = keyboard[3];
assign enter = keyboard[4];
assign esc = keyboard[5];
assign pause = keyboard[6];
input reset;
input clock;
input reduced_clock;
input [2:0]memory_read_data;
output reg [7:0]memory_address; //10 by 20 address on tetrid grid
output reg [2:0]memory_write_data;
output reg memory_write_enable;
output reg [1:0]state_output; //Main FSM state_output
output reg new_block; //signal for new block generation; current block has been completely passed down
output reg [0:15]block_shape; //current updating block
output reg [3:0]block_location_x;
output reg [4:0]block_location_y;
output reg [2:0]block_color;
reg [2:0]block_shape_ID;
reg [1:0]block_rotation_ID;
wire [0:15]rotate_block_shape;
reg [2:0]next_block_shape_ID;
output reg [0:15]next_block_shape; // next block selector
output reg [2:0]next_block_color;
wire [2:0]RNGblockshape;
wire [1:0]RNGBlockID;
rotatedBlock RotationDecode(block_shape_ID, block_rotation_ID, rotate_block_shape, clock);
rotatedBlock RNGDecode(RNGblockshape, 0, rand_block_shape, clock);
RNG blockGen(clock, RNGblockshape, rand_block_color);
wire [0:15]rand_block_shape; // next block selector
wire [2:0]rand_block_color;
output reg [0:15]score;
output [3:0]statedebug;
assign statedebug = internal_state;
reg [3:0]internal_state;
// Internal_state
// 0000 A loadgame
// 0001 B start
// 0010 C new_block
// 0011 D new_block_legal_check
// 0100 E new_block_memory_write
// 0101 F new_block_draw
// 0110 G move_block
// 0111 H move_block_legal_check
// 1000 I move_block_memory_write
// 1001 J move_block_draw
// 1010 K row_check
// 1011 L remove_row_memory_write
// 1100 M game_over
// 1101 N shift_block_legal_check
// 1110 O rotate_block_legal_check
// 1111 P ERROR
parameter A = 4'b0000,
B = 4'b0001,
C = 4'b0010,
D = 4'b0011,
E = 4'b0100,
F = 4'b0101,
G = 4'b0110,
H = 4'b0111,
I = 4'b1000,
J = 4'b1001,
K = 4'b1010,
L = 4'b1011,
M = 4'b1100,
N = 4'b1101,
O = 4'b1110,
P = 4'b1111;
initial
begin
legal_move_counter <= 0;
internal_state <= A;
counter_x <= 0;
counter_y <= 0;
end
reg [1:0]counter_x; //maximum of "3", x coordinate on 4 by 4 grid
reg [1:0]counter_y; //maximum of "3", y coordinate on 4 by 4 grid
output reg [3:0] memory_counter_x; //game wipers and checkers
output reg [4:0] memory_counter_y;
reg [4:0]memory_incrementer_y; //for row wipes
output reg hit; //collision dection bools
output reg column_exists; //collision dection bools
reg row_exists;
reg hold_a_cycle;
reg next_cycle_draw; // for delaying memory writing
reg increment_memory;
reg left_right;
reg user_or_auto;
reg [0:15]last_block_shape; //current updating block
reg [3:0]last_block_location_x;
reg [4:0]last_block_location_y;
reg[2:0]above_color;
reg memory_new_or_delete; //0: delete , 1:new
reg[31:0] legal_move_counter;
reg[31:0] legal_shift_counter;
//assign legal_move = (legal_change) ? 1'b1 : clock;
reg newgame;
always@(posedge clock)
begin
if (reset || esc)
begin
internal_state <= B; // state
counter_x <= 0; //block counter, 00->11
counter_y <= 0;
memory_counter_x <= 0; //memory counters, 0-> 15
memory_counter_y <= 0; // 0 -> 31
memory_write_enable <= 0; //various memory control bools
memory_new_or_delete <= 0;
next_cycle_draw <= 0;
increment_memory <= 0;
memory_incrementer_y <= 0; //row wipe counter set to 0
above_color <= 0; //row wipe color
user_or_auto <=1; //automatic downshift
hit <=0; //collision bools
column_exists <= 0;
row_exists <= 0;
block_shape<= 0; //block information
block_location_x<= 0;
block_location_y<= 0;
block_color<= 0;
block_shape_ID<= 0;
block_rotation_ID<= 0;
next_block_shape_ID <=0;
next_block_shape<= 0; //next block in line
next_block_color<= 0;
end
else
begin
case (internal_state)
A:// 0000 A loadgame
begin //not done
internal_state <= B;
end
B:// 0001 B start - wipes memory
begin //parts not done: telling DATAPATH that game start.
memory_write_data <= BLANK_COLOR;
memory_write_enable <= 1;
memory_address <=memory_counter_x + memory_counter_y * GRID_SIZE_X;
if (memory_counter_y < GRID_SIZE_Y)
begin
if (memory_counter_x < GRID_SIZE_X)
memory_counter_x <= memory_counter_x + 1;
else
begin
memory_counter_y <= memory_counter_y +1;
memory_counter_x <= 0;
end
end
else
begin
block_shape<= 0;
block_location_x<= 0;
block_location_y<= 0;
block_color<= 0;
block_shape_ID<= 0;
block_rotation_ID<= 0;
next_block_shape<= 0;
next_block_color<= 0;
next_block_shape_ID <=0;
internal_state <= C;
// hit <= 1;
memory_write_enable <= 0;
memory_counter_y <= 0;
memory_counter_x <= 0;
newgame <= 1;
end
end
C:// 0010 C new_block generate new block
begin //not done
state_output <= 2'b00;
//for next_block, live implentation.
if (newgame)
begin
// next_block_shape <= DEBUG_2;
next_block_shape <= rand_block_shape;
next_block_shape_ID <= block_shape_ID;
next_block_color <= rand_block_color;
newgame <= 0;
end
else
begin
block_shape <= next_block_shape;
// block_shape <= DEBUG_2;
block_color <= next_block_color;
next_block_shape <= rand_block_shape;
next_block_shape_ID <= block_shape_ID;
// next_block_shape <= DEBUG_2;
next_block_color <= rand_block_color;
block_shape_ID<= 0;
internal_state <= D;
end
end
D:// 0011 D new_block_legal_check checks if gameover (in other words, the block is stuck at top)
begin //not done
block_location_x <= GRID_CENTER_LOCATION_X - x_corner; //shifts up-left when loading new block to remove blank space at top
block_location_y <= GRID_CENTER_LOCATION_Y - y_corner;
counter_x <= 0;
counter_y <= 0;
internal_state <= E;
memory_address <=0;
hold_a_cycle <=0;
end
E:// 0100 E new_block_memory_write if legal check passes, write new block into memory
begin
if (hold_a_cycle)
begin
internal_state <= F;
new_block <= 1'b0;
memory_write_enable <= 1'b0;
hold_a_cycle <=0;
end
else if (memory_write_enable )
memory_write_enable <= 1'b0;
else
begin
if (block_shape[{counter_y,counter_x}])
begin
if (block_location_y == 5'b11111)
memory_address <= (block_location_x + counter_x) + (counter_y - 1) * GRID_SIZE_X;
else
memory_address <= (block_location_x + counter_x) + (block_location_y + counter_y) * GRID_SIZE_X;
memory_write_data <= block_color;
memory_write_enable <= 1'b1;
end
if (counter_x < BLOCKSIZE - 1)
counter_x <= counter_x + 1;
else
begin
if (counter_x == (BLOCKSIZE-1) && counter_y == (BLOCKSIZE-1))
begin
counter_x <=0;
counter_y <=0;
hold_a_cycle <=1;
end
else
begin
counter_y <= counter_y + 1;
counter_x <= 0;
end
end
end
end
F:// 0101 F new_block_draw
begin
if (new_block == 1'b0) // there has to be a new block, this is an internal bool
// with exterior implications.
begin
new_block <= 1'b1;
end
else
begin
internal_state <= G;
// internal_state <= C;
state_output <= 2'b01;
//state_output <= 2'b10;
// this may cause problems, it SHOULD not.
legal_move_counter <= 0;
end
end
G:// 0110 G move_block
begin
legal_move_counter <= legal_move_counter + 1;
new_block = 1'b0;
state_output <= 2'b00; // backup, technically not needed
if (legal_move_counter >= MOVEDELAY)
begin
memory_counter_x <= 0;
memory_counter_y <= 0;
internal_state <= H;//move down, not rotate
legal_move_counter <= 0;
hit <= 0;
column_exists <= 0;
hold_a_cycle<=0;
memory_address <= memory_counter_y * GRID_SIZE_X
+ block_location_y * GRID_SIZE_X
+ block_location_x
+ memory_counter_x;
user_or_auto <=1;
end
else if( legal_shift_counter == 0 && (up||left||right))
begin
if(up) //else
begin
memory_counter_x <= 0;
memory_counter_y <= 0;
internal_state <= O;//rotate
hit <= 0;
column_exists <= 0;
hold_a_cycle<=0;
memory_address <= memory_counter_y * GRID_SIZE_X
+ block_location_y * GRID_SIZE_X
+ block_location_x
+ memory_counter_x;
user_or_auto <=0;
end
else if(left || right)
begin
if(left)
begin
left_right <= 0;
memory_counter_x <= BLOCKSIZE -1;
end
else if (right)
begin
left_right <= 1;
memory_counter_x <= 0;
end
else
internal_state <= P; //left || right triggered, but neither left or right actually did
memory_counter_y <= 0;
internal_state <= N;//move to side
last_block_location_x <= block_location_x;
last_block_location_y <= block_location_y;
last_block_shape <= block_shape;
hit <= 0;
row_exists <= 0;
hold_a_cycle <=1;
user_or_auto <=0;
end
legal_shift_counter <= legal_shift_counter +1;
end
else if( legal_shift_counter <SHIFTDELAY && legal_shift_counter > 0)
legal_shift_counter <= legal_shift_counter + 1;
else
legal_shift_counter <= 0;
end
H: // glorious collision dection algorithems
begin
// 0111 H move_block_legal_check - can block fall?
if (hold_a_cycle)
begin
if (block_location_y == 5'b11111)
memory_address <= (block_location_x + memory_counter_x) + (memory_counter_y - 1) * GRID_SIZE_X;
else
memory_address <= (block_location_x + memory_counter_x) + (block_location_y + memory_counter_y) * GRID_SIZE_X;
hold_a_cycle <= 0;
end
else
begin
if(~hit)
begin
if(block_shape[(memory_counter_y * BLOCKSIZE + memory_counter_x)] && memory_counter_y < BLOCKSIZE)
begin
column_exists <= 1;
increment_memory <=1;
end
else if (column_exists) //this ends up always false
begin
if( memory_read_data != BLANK_COLOR)
hit <= 1;
else if (block_location_y + memory_counter_y >= GRID_SIZE_Y)
hit <= 1;
else
begin
column_exists <=0;
memory_counter_y <= 0;
memory_counter_x <= memory_counter_x + 1;
// hold_a_cycle<=1;
increment_memory <=1;
end
end
else
increment_memory <=1;
// else if (block_location_y + memory_counter_y >= 10)//debug
// hit <= 1;
if (increment_memory)
begin
increment_memory <=0;
if (memory_counter_x < BLOCKSIZE) // && ~hold_a_cycle
begin
if (memory_counter_y < BLOCKSIZE+1)
begin
memory_counter_y <= memory_counter_y + 1;
end
else
begin
column_exists <=0;
memory_counter_x <= memory_counter_x + 1;
memory_counter_y <= 0;
end
hold_a_cycle<=1;
end
else
begin
memory_counter_y <= 0;
memory_counter_x <= 0;
memory_new_or_delete <= 0;
internal_state <= I;//block can move down should be I
next_cycle_draw<=0;
block_location_y <= block_location_y + 1;
last_block_location_x <= block_location_x;
last_block_location_y <= block_location_y;
end
end
end
else//otherwise, block cannot make the move
begin
column_exists <=0;
memory_counter_y <= GRID_SIZE_Y -1;
memory_counter_x <= 2;
state_output <= 0;
row_exists <= 0;
hold_a_cycle <=1;
next_cycle_draw <= 0;
internal_state <= K; // goes to rowcheck
end
end
end
I:// 1000 I move_block_memory_write (and wipe)
begin
if (next_cycle_draw)
begin
internal_state <= J;
memory_write_enable <= 1'b0;
next_cycle_draw <=0;
end
else if (memory_write_enable)
memory_write_enable <= 1'b0;
else
begin
begin
if (user_or_auto && block_shape[{counter_y,counter_x}]) //move down
begin
if (~memory_new_or_delete) //deleting old blocks
memory_address <= (block_location_x + counter_x) + (block_location_y + counter_y - 1) * GRID_SIZE_X;
else//writing new blocks
memory_address <= (block_location_x + counter_x) + (block_location_y + counter_y) * GRID_SIZE_X;
memory_write_data <= memory_new_or_delete ? block_color : BLANK_COLOR;
memory_write_enable <= 1'b1;
end
else if(~user_or_auto) //rotation or shifting
if(memory_new_or_delete ? block_shape[{counter_y,counter_x}] : last_block_shape[{counter_y,counter_x}] )
begin
memory_address <= memory_new_or_delete ?
((block_location_x + counter_x) + (block_location_y + counter_y) * GRID_SIZE_X)
:
((last_block_location_x + counter_x) + (last_block_location_y + counter_y) * GRID_SIZE_X);
memory_write_data <= memory_new_or_delete ? block_color : BLANK_COLOR;
memory_write_enable <= 1'b1;
end
// else
// memory_write_enable <= 1'b0;
if (counter_y < BLOCKSIZE) // always true, could cause issues later
begin
if (counter_x < BLOCKSIZE -1)
counter_x <= counter_x + 1;
else
begin
if (counter_x == (BLOCKSIZE-1) & counter_y == (BLOCKSIZE-1))
begin
if (~memory_new_or_delete)
begin
memory_new_or_delete <= 1;
counter_x <=0;
counter_y <=0;
end
else if (memory_new_or_delete)
begin
next_cycle_draw <= 1'b1;
counter_x <=0;
counter_y <=0;
end
end
else
begin
counter_y <= counter_y + 1;
counter_x <= 0;
end
end
end
else // if the if is always true, this is never called...
begin
memory_write_enable <= 1'b0;
internal_state <= P;
end
end
end
end
J:// 1001 J move_block_draw
begin
if (state_output == 2'b0)
begin
state_output <= 2'b10;
//state_output <= 2'b01;
end
else
begin
state_output <= 2'b00;
internal_state <= G;
legal_move_counter <=0;
end
end
K:// 1010 K row_check
begin
if (hold_a_cycle)
begin
memory_address <= memory_counter_x + memory_counter_y * GRID_SIZE_X;
hold_a_cycle <= 0;
if (next_cycle_draw)
begin
next_cycle_draw <= 0;
internal_state <= L;
increment_memory <=0;
memory_incrementer_y <= memory_counter_y + 1 ;
above_color <=0;
end
end
else if( memory_counter_y >= 0 && memory_counter_y != 4'b1111)
begin
if(memory_counter_x < GRID_SIZE_X) // as long as y pointer is under the top of box
begin
if(memory_read_data == BLANK_COLOR) //if a pixel is black on this row, go to the row above, restart countdown
begin
memory_counter_y <= memory_counter_y - 1;
memory_counter_x <= 2;
hold_a_cycle <=1;
end
else
begin //goto next super-pixel
memory_counter_x <= memory_counter_x + 1;
hold_a_cycle <=1;
end
end
else
begin
next_cycle_draw <= 1;
hold_a_cycle <= 1;
//delete this memory_y row
end
end
else
internal_state <= C; // new block time
end
L:// 1011 L remove_row_memory_write, actually a mini 4-state FSM
begin
if (memory_write_enable)
begin
memory_write_enable <=0;
if(memory_incrementer_y != 4'b1111)
begin // as long as y pointer is under the top of box
if(memory_counter_x < GRID_SIZE_X)
begin
memory_counter_x <= memory_counter_x + 1;
end
else
begin
memory_incrementer_y <= memory_incrementer_y - 1;
memory_counter_x <= 2;
end
end
else
begin
state_output <= 2'b10;
internal_state <= K;
end
end
else if (~hold_a_cycle)
begin
if (~increment_memory)
begin
memory_write_enable <=0;
memory_address <= memory_counter_x + (memory_incrementer_y - 1) * GRID_SIZE_X;
hold_a_cycle <=1;
end
else if(increment_memory)
begin
memory_write_data <= above_color;
memory_address <= memory_counter_x + (memory_incrementer_y) * GRID_SIZE_X;
hold_a_cycle <= 1;
end
end
else if (hold_a_cycle)
begin
if (~increment_memory)
begin
above_color <= memory_read_data;
hold_a_cycle <=0;
increment_memory <=1;
end
else if (increment_memory)
begin
memory_write_enable <=1;
increment_memory <=0;
hold_a_cycle <=0;
end
end
end
M:// 1100 M game_over
begin
end
N:// 1101 N shift_block_legal_check
begin
if (hold_a_cycle)
begin
if (block_location_y == 5'b11111)
memory_address <= (block_location_x + memory_counter_x) + (memory_counter_y - 1) * GRID_SIZE_X;
else
if (memory_counter_x == 4'b1111)
memory_address <= (block_location_x - 1) + (block_location_y + memory_counter_y) * GRID_SIZE_X;
else
memory_address <= (block_location_x + memory_counter_x) + (block_location_y + memory_counter_y) * GRID_SIZE_X;
hold_a_cycle <= 0;
end
else
begin
if(~hit)
begin
if(block_shape[(memory_counter_y * BLOCKSIZE + memory_counter_x)] && memory_counter_x != 4'b1111)
begin
row_exists <= 1;
increment_memory <=1;
end
else if (row_exists && ~left_right) //left
begin
if( memory_read_data != BLANK_COLOR)
hit <= 1;
else if (memory_counter_x == 4'b1111 && block_location_x -1 <= 1)
hit <= 1;
else if (block_location_x + memory_counter_x <= 1)
hit <= 1;
else
begin
row_exists <=0;
// memory_counter_x <= 0;
memory_counter_x <= BLOCKSIZE - 1;
memory_counter_y <= memory_counter_y + 1;
hold_a_cycle <= 1;
// increment_memory <=1;
end
end
else if (row_exists && left_right) //right
begin
if( memory_read_data != BLANK_COLOR)
hit <= 1;
else if (block_location_x + memory_counter_x >= GRID_SIZE_X)
hit <= 1;
else
begin
row_exists <=0;
memory_counter_x <= 0;
memory_counter_y <= memory_counter_y + 1;
// hold_a_cycle<=1;
increment_memory <=1;
end
end
else
increment_memory <=1;
// else if (block_location_y + memory_counter_y >= 10)//debug
// hit <= 1;
if (increment_memory)
begin
increment_memory <=0;
if (~left_right && memory_counter_y < BLOCKSIZE) //left &&~hold_a_cycle
begin
if (memory_counter_x == 4'b1111)
begin
row_exists <=0;
memory_counter_y <= memory_counter_y + 1;
memory_counter_x <= BLOCKSIZE - 1;
end
else if (memory_counter_x >= 0) //overflow case
begin
memory_counter_x <= memory_counter_x - 1;
end
else
internal_state <= P; //ERROR
hold_a_cycle<=1;
end
else if (left_right && memory_counter_y < BLOCKSIZE) //right &&~hold_a_cycle
begin
if (memory_counter_x < BLOCKSIZE) //+1
begin
memory_counter_x <= memory_counter_x + 1;
end
else
begin
row_exists <=0;
memory_counter_y <= memory_counter_y + 1;
memory_counter_x <= 0;
end
hold_a_cycle<=1;
end
else
begin
memory_counter_y <= 0;
memory_counter_x <= 0;
memory_new_or_delete <= 0;
internal_state <= I;//block can shift
next_cycle_draw<=0;
user_or_auto <=0;
if(left_right) //right
begin
block_location_x <= block_location_x + 1;
end
else if (~left_right)//left
begin
block_location_x <= block_location_x - 1;
end
end
end
end
else//otherwise, block cannot make the move
begin
column_exists <=0;
memory_counter_y <= 0;
memory_counter_x <= 0;
internal_state <= G; //shifting failed, go back to try and move
legal_move_counter <=0;
end
end
end
O:// 1110 O rotate_block_legal_check
begin
if(hit)
hit <=0;
else if (~hold_a_cycle)
begin
last_block_shape<=block_shape;
block_rotation_ID<= block_rotation_ID+1;
hold_a_cycle <=1;
hit <=1;
end
else
begin
block_shape <= rotate_block_shape;
internal_state <= I;
user_or_auto <=0;
memory_counter_y <= 0;
memory_counter_x <= 0;
memory_new_or_delete <= 0;
next_cycle_draw<=0;
end
end
P:// 1111 P ERROR, gamecrash
begin
end
endcase
end
end
wire [1:0]x_corner, y_corner;
find_top_left topleft(clock, block_shape, x_corner, y_corner);
parameter
BLOCK_0_1 = 16'b0000011001100000,
BLOCK_I_1 = 16'b0000111100000000,
BLOCK_I_2 = 16'b0010001000100010,
BLOCK_S_1 = 16'b0000001101100000,
BLOCK_S_2 = 16'b0010001100010000,
BLOCK_Z_1 = 16'b0000011000110000,
BLOCK_Z_2 = 16'b0001001100100000,
BLOCK_L_1 = 16'b0000011101000000,
BLOCK_L_2 = 16'b0010001000110000,
BLOCK_L_3 = 16'b0001011100000000,
BLOCK_L_4 = 16'b0110001000100000,
BLOCK_J_1 = 16'b0000011100010000,
BLOCK_J_2 = 16'b0011001000100000,
BLOCK_J_3 = 16'b0100011100000000,
BLOCK_J_4 = 16'b0010001001100000,
BLOCK_T_1 = 16'b0000011100100000,
BLOCK_T_2 = 16'b0010001100100000,
BLOCK_T_3 = 16'b0010011100000000,
BLOCK_T_4 = 16'b0010011000100000,
DEBUG_1 = 16'b1111100110011111,
DEBUG_2 = 16'd52428;
endmodule
module find_top_left
(
input clock,
input [0:15]block_shape,
output reg [1:0]x_corner,
output reg [1:0]y_corner
);
always@(posedge clock)
begin
case (block_shape)
BLOCK_0_1:
begin
x_corner = 2'b01;
y_corner = 2'b01;
end
BLOCK_I_1:
begin
x_corner = 2'b00;
y_corner = 2'b01;
end
BLOCK_I_2:
begin
x_corner = 2'b10;
y_corner = 2'b00;
end
BLOCK_S_1:
begin
x_corner = 2'b01;
y_corner = 2'b01;
end
BLOCK_S_2:
begin
x_corner = 2'b10;
y_corner = 2'b00;
end
BLOCK_Z_1:
begin
x_corner = 2'b01;
y_corner = 2'b01;
end
BLOCK_Z_2:
begin
x_corner = 2'b10;
y_corner = 2'b00;
end
BLOCK_L_1:
begin
x_corner = 2'b01;
y_corner = 2'b01;
end
BLOCK_L_2:
begin
x_corner = 2'b10;
y_corner = 2'b00;
end
BLOCK_L_3:
begin
x_corner = 2'b01;
y_corner = 2'b00;
end
BLOCK_L_4:
begin
x_corner = 2'b01;
y_corner = 2'b00;
end
BLOCK_J_1:
begin
x_corner = 2'b01;
y_corner = 2'b01;
end
BLOCK_J_2:
begin
x_corner = 2'b10;
y_corner = 2'b00;
end
BLOCK_J_3:
begin
x_corner = 2'b01;
y_corner = 2'b00;
end
BLOCK_J_4:
begin
x_corner = 2'b01;
y_corner = 2'b00;
end
BLOCK_T_1:
begin
x_corner = 2'b01;
y_corner = 2'b01;
end
BLOCK_T_2:
begin
x_corner = 2'b10;
y_corner = 2'b00;
end
BLOCK_T_3:
begin
x_corner = 2'b01;
y_corner = 2'b00;
end
BLOCK_T_4:
begin
x_corner = 2'b01;
y_corner = 2'b00;
end
DEBUG_1:
begin
x_corner = 2'b00;
y_corner = 2'b00;
end
DEBUG_2:
begin
x_corner = 2'b00;
y_corner = 2'b00;
end
endcase
end
parameter
BLOCK_0_1 = 16'b0000011001100000,
BLOCK_I_1 = 16'b0000111100000000,
BLOCK_I_2 = 16'b0010001000100010,
BLOCK_S_1 = 16'b0000001101100000,
BLOCK_S_2 = 16'b0010001100010000,
BLOCK_Z_1 = 16'b0000011000110000,
BLOCK_Z_2 = 16'b0001001100100000,
BLOCK_L_1 = 16'b0000011101000000,
BLOCK_L_2 = 16'b0010001000110000,
BLOCK_L_3 = 16'b0001011100000000,
BLOCK_L_4 = 16'b0110001000100000,
BLOCK_J_1 = 16'b0000011100010000,
BLOCK_J_2 = 16'b0011001000100000,
BLOCK_J_3 = 16'b0100011100000000,
BLOCK_J_4 = 16'b0010001001100000,
BLOCK_T_1 = 16'b0000011100100000,
BLOCK_T_2 = 16'b0010001100100000,
BLOCK_T_3 = 16'b0010011100000000,
BLOCK_T_4 = 16'b0010011000100000,
DEBUG_1 = 16'b1111100110011111,
DEBUG_2 = 16'd52428;
endmodule[/code]
The main logic code, if you go through it, you'll realize it's not 100% complete or working (properly).
[QUOTE=pentium;43032825]Tried adding a piezoelectric speaker to my geiger counter.
[IMG]http://i11.photobucket.com/albums/a166/ballsandy/IMG_3960.jpg[/IMG]
...but it really feels like it needs an amp.[/QUOTE]
try to not tape it on solid like that. I've dismantled a few items with piezoelectric transducers, and they all were mounted using a round sticky rubberseal only.
[QUOTE=Chryseus;43028311]Time to go shopping then, buy a nice variable power supply or build your own.[/QUOTE]
Anything you can recommend for the cheap?
[QUOTE=DrDevil;43034098]try to not tape it on solid like that. I've dismantled a few items with piezoelectric transducers, and they all were mounted using a round sticky rubberseal only.[/QUOTE]
Yes having a small air gap greatly improves the sound, as for an amp since you already have high voltage available it would be worth making a high voltage piezo driver.
[QUOTE=nutcake;43035241]Anything you can recommend for the cheap?[/QUOTE]
Most of the cheaper bench power supplies on ebay are generally perfectly acceptable quality.
[url]http://www.ebay.com/itm/PRO-30V-5A-DIGITAL-DC-POWER-SUPPLY-PRECISION-VARIABLE-AGJUSTABLE-/331076259088?pt=LH_DefaultDomain_0&hash=item4d15aecd10[/url]
[url]http://www.ebay.com/itm/Linear-Bench-Power-Supply-Adjustable-0-30-Volts-0-5-Amps-CSI530S-/221060865418?pt=LH_DefaultDomain_0&hash=item3378411d8a[/url]
[url]http://www.ebay.com/itm/0-30V-3A-3AMP-Digital-DC-Power-Supply-Lab-Precision-Variable-110-220V-Adjustable-/131021090710?pt=LH_DefaultDomain_0&hash=item1e81772f96[/url]
For example.
[QUOTE=Chryseus;43035348]
Most of the cheaper bench power supplies on ebay are generally perfectly acceptable quality.
[url]http://www.ebay.com/itm/PRO-30V-5A-DIGITAL-DC-POWER-SUPPLY-PRECISION-VARIABLE-AGJUSTABLE-/331076259088?pt=LH_DefaultDomain_0&hash=item4d15aecd10[/url]
[url]http://www.ebay.com/itm/Linear-Bench-Power-Supply-Adjustable-0-30-Volts-0-5-Amps-CSI530S-/221060865418?pt=LH_DefaultDomain_0&hash=item3378411d8a[/url]
[url]http://www.ebay.com/itm/0-30V-3A-3AMP-Digital-DC-Power-Supply-Lab-Precision-Variable-110-220V-Adjustable-/131021090710?pt=LH_DefaultDomain_0&hash=item1e81772f96[/url]
For example.[/QUOTE]
Shipping is 70$.
Yeah, no thanks.
[QUOTE=nutcake;43035534]Shipping is 70$.
Yeah, no thanks.[/QUOTE]
Look on the German ebay, you should be able to get a local supplier easy enough.
Assuming flagdog is correct of course.
Sorry, you need to Log In to post a reply to this thread.